I configured REST webservice on Moodle 3.0.5 to use function core_course_get_courses
which is supposed to return a response containing basic info about all available courses.
This is the URL I've been using:
https://example.com/webservice/rest/server.php?wstoken=713898e3fcaf9ead2218eb7565993230&wsfunction=core_course_get_courses&moodlewsrestformat=json
And, this is what I get:
{
"exception": "required_capability_exception",
"errorcode": "nopermissions",
"message": "Sorry, but you do not currently have permissions to do that (View courses without participation)"
}
The permission in question has been set from the start, that is:
moodle/course:view
It does not have any effect. I even allowed everything, some few hundred permissions just to see if it would work, but still no effect.
I used another function with the same service, it does work!:
core_enrol_get_enrolled_users
Another important fact is that the core_course_get_courses
function works on a local, development machine with fresh installation of Moodle. The production environment has 50 additional plugins installed. The debugging, "extra Moodle debug messages for developers" has been enabled but there are no errors shown.
What could be the cause for this?
PS Dev. machine is Ubuntu 14.04
Does the user with the token have access to the capability?
Find the user with the token via site admin -> plugins -> web services -> manage tokens
or direct to /admin/settings.php?section=webservicetokens
Then check the users capability via site admin -> users -> permissions -> check system permissions
or direct to /admin/roles/check.php?contextid=1
If that looks okay, then check if the user is in the list of other users for the course - https://docs.moodle.org/31/en/Other_users
Go to a course, then course admin -> users -> other users
or direct to /enrol/otherusers.php?id=#
(#=courseid)
Is the user in that list?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.