'Moodle Data Request

I want to pass the user id (100) to moodle and then get a JSON string about the stored data of the user with the id (100). Is there a way or a web service for this?

Thx



Solution 1:[1]

First of all, you need to enable Moodle web services, you can follow this link, then add the "core_user_get_users" function to your external web service, then you can create criteria to search and get user data.

Samples:

webservice endpoint: https://<MOODLE_URL>/webservice/rest/server.php?wstoken=<YOUR_TOKEN>&wsfunction=core_user_get_users&moodlewsrestformat=json&criteria[0][key]=username&criteria[0][value]=<USERNAME>
webservice endpoint: https://<MOODLE_URL>/webservice/rest/server.php?wstoken=<YOUR_TOKEN>&wsfunction=core_user_get_users&moodlewsrestformat=json&criteria[0][key]=id&criteria[0][value]=<ID>

For other response formats change "moodlewsrestformat" in the request.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Milad Karimiyan