Problems with webservice access

Problems with webservice access

by Salome Tkhilaishvili -
Number of replies: 3

I want to use moodle's  standard rest api for adding users and assign role to this newly created users , but  when i try to invoke my service from postman here is my url for rest service invocation:

http://test-exam.sda.com/webservice/rest/server.php?wstoken=42901bb69a936dfcc37fda898a3c4c08&wsfunction=core_user_create_users&moodlewsrestformat=json&; users[0][username]=liamneeson&users[0][password]=li@mR0cks!&users[0][firstname]=Liam&users[0][lastname]=Neeson&users[0][email]=liamneeson@refineddata.com

the token which i have used for rest service invocation is generated for web service user , who have permission on rest service, enrolment and also user create (i have made role which have this permissions and after that assign this role to my web service user) ,i have activated service also but when i try to use this token i got this error:

{

    "exception": "webservice_access_exception",

    "errorcode": "accessexception",

    "message": "Access control exception"

}

I have assign this role to admin user and then i have generated token for admin user but in this case i got the same error i mean webservice_access_exception, what should i change to be able to create users?


Average of ratings: -
In reply to Salome Tkhilaishvili

Re: Problems with webservice access

by Ghislain Nono Gueye -

Unfortunately, I do not have an answer to your question, but another question. Is it possible to access Moodle's APIs as a teacher and not a site administrator?

In reply to Ghislain Nono Gueye

Re: Problems with webservice access

by Mayank Tyagi -

Hi Ghislain,

Yes, it is possible to access Moodle's APIs like Web Services as a teacher. For web services just create a token for the user for which you want to create access capability. you can create a token from Site Administration > Plugins > Webservices > Manage Tokens or hit http://example.com/admin/settings.php?section=webservicetokens.

Regards,

Mayank Tyagi

Average of ratings: Useful (1)
In reply to Mayank Tyagi

Re: Problems with webservice access

by Ghislain Nono Gueye -

Thank you very much for your response. Actually, I am a teacher at a university and after searching for a few days, I was not able to find out how to access Site Administration. My best best is that only the administration of the university has such an access. If that is the case, does that mean that I need to ask them to create a token for me so I can access the APIs?


Sincere thanks.