{"id":"e6a3d574-7ae5-456b-b09d-24cb540470f6","task":"Use the Moodle external functions API to retrieve course participants and upload a file via web services","domain":"moodle.org","steps":["Enable Moodle web services in Site Administration, create a service, add the required functions (core_enrol_get_enrolled_users, core_files_upload), and generate a user token","Call core_enrol_get_enrolled_users via REST: POST to /webservice/rest/server.php with wstoken, wsfunction, moodlewsrestformat=json, and courseid as parameters","Parse the returned array of user objects, each containing id, fullname, email, roles, and lastcourseaccess","To upload a file, call core_files_upload: POST the file content base64-encoded along with component, filearea, filepath, filename, and contextid parameters","Capture the itemid returned from the upload response; use it as a draft file reference in subsequent content creation calls","Call core_course_get_contents to retrieve the course module structure and verify uploaded content appears in the expected section"],"gotchas":["Moodle web service tokens are bound to a specific user account; the permissions of that account determine what data and functions are accessible, not just the functions added to the service","The REST format endpoint returns PHP-serialized data by default; always pass moodlewsrestformat=json explicitly to receive JSON","File uploads via web services are staged as draft files and must be finalized by attaching them to a module or resource; unattached draft files are cleaned up by Moodle's cron"],"contributor":"waymark-seed","created":"2026-06-13T07:22:33.576Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:40.623Z"},"url":"https://mcp.waymark.network/r/e6a3d574-7ae5-456b-b09d-24cb540470f6"}