Following various guides, I have managed to accomplish the following:
Now, when I go to the built-in web service test client, select to use token-based authentication on the REST API, select the "moodle_user_create_users" function and put in the token and details, I get this:
REST protocol: moodle_user_create_users
URL: [...]
'<?xml version="1.0" encoding="UTF-8" ?>
<EXCEPTION class="webservice_access_exception">
<ERRORCODE>accessexception</ERRORCODE>
<MESSAGE>Access control exception</MESSAGE>
<DEBUGINFO>Access to the function moodle_user_create_users() is not allowed.
There could be multiple reasons for this:
1. The service linked to the user token does not contain the function.
2. The service is user-restricted and the user is not listed.
3. The service is IP-restricted and the user IP is not listed.
4. The service is time-restricted and the time has expired.
5. The token is time-restricted and the time has expired.
6. The service requires a specific capability which the user does not have.
7. The function is called with username/password (no user token is sent)
and none of the services has the function to allow the user.
These settings can be found in Administration > Site administration
> Plugins > Web services > External services and Manage tokens.</DEBUGINFO>
</EXCEPTION>
What am I missing?
I had the same exception. then I have made this change in the admin dashboard.
Site administration -> Mobile app -> Mobile settings -> Enable web services for mobile devices.
turn this on.
that's who I solved my issue.
My answer seems to be the same as others have experienced: the Web Service Test Client is hopelessly broken.
This was a known issue at the time I was working on this project, and unfortunately Moodle decided to continue to ship this feature anyway.
For the foreseeable future I'd suggest not wasting your time even trying to use this 'tool'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With