Webservices parameters for "moodle_user_get_users_by_courseid" / "moodle_enrol_get_enrolled_users"

Webservices parameters for "moodle_user_get_users_by_courseid" / "moodle_enrol_get_enrolled_users"

by Juan A -
Number of replies: 1

Hi all.

This is my first post.

I'm trying to get the enrolled users in a course using webservices and the REST protocol. I'm programming in python and previously i have used other webservices as get_courses or create_users. The problem is that I can't put well the parameters (I think).

<EXCEPTION class="webservice_access_exception">

I looked at the API information, and has required arguments: course and options. Options is a list that includes name and value.

1. What is value?
2. Why must the name? Do not represented that already obtained from the id?

- courseid (Requerido)
int   //course id

- options (Requerido)
REST (parámetros POST)
options[0][name]= string
options[0][value]= string

Would something like that?

function = 'moodle_user_get_users_by_courseid&courseid=5&options[0][name]=Course2&options[0][value]=string'    

It also happen using "moodle_enrol_get_enrolled_users"

Any suggestions?

Regards

Average of ratings: -
In reply to Juan A

Re: Webservices parameters for "moodle_user_get_users_by_courseid" / "moodle_enrol_get_enrolled_users"

by Jérôme Mouneyrac -

Hi Juan,

what Moodle version have you got? With the latest version + Moodle debug > NORMAL, the error message gives more clue than just the basic webservice_access_exception. Download the master branch from https://github.com/moodle/moodle.

webservice_access_exception is not related to the function, it's more an issue with the user/token authentication.

From memory, check:

* user has the right protocol capability
* ip restriction (on the token or on the restricted user)
* web service advanced feature is not enabled
* valid date time (on the token or on the restricted user)
* service is not enabled
* service doesn't contain the function
* token doesn't exist 

Going through http://docs.moodle.org/20/en/How_to_create_and_enable_a_web_service should resolve the access error.

Working with the latest web service improvement will save you a lot of time. The access exception is far easier to resolve than an error on the parameters where you really want the last improvement (Moodle tells you what parameter is wrong when Moodle DEBUG mode > NORMAL).

Cheers,
Jerome