Cannot get course list on web services

Cannot get course list on web services

by Wayne Kruger -
Number of replies: 1

Hi guys, I am new to moodle and I am trying to retrieve a list of courses via the web service. I followed all the instructions on enabling the web services, creating a user, roles, services, permissions, adding functions, etc.

I am calling:

http://[MOODLE_URL]/webservice/rest/server.php?wstoken=[TOKEN]&moodlewsrestformat=json&wsfunction=core_course_get_courses

But getting back

{"exception": "moodle_exception","errorcode": "errorcoursecontextnotvalid","message": "You cannot execute functions in the course context (course id:2). The context error message was: Course or activity not accessible."}


I am sure it is just some kind of permission or setting somewhere, can any point me in the correct direction?

Much appreciated

Average of ratings: -
In reply to Wayne Kruger

Re: Cannot get course list on web services

by Wayne Kruger -

I changed the function name to core_course_get_courses_by_field and I am getting data back.

In case anyone else has this issue...

Average of ratings: Useful (1)