0

I am trying to enroll a user on my Moodle site via using the Moodle API. My Moodle instance is hosted on AWS and all relevant ports are open and listening. So, from the network perspective, I can commit that is all ok.

The steps I have already done based on Moodle Documentation:

  1. I have enabled web services on Administration > Mobile app >Mobile settings
  2. I have gone through the 10 steps on the overview of allowing an external system to control Moodle as explained in the documentation (shown also in this Youtube video)

For testing purposes, I am using Postman. Some requests are going through (e.g. getting the token for a certain user, getting the list of all courses, etc.)

Example: enter image description here

But when I try to i.e. create a user or enroll a user in an existing course I am getting this error:

{
    "exception": "webservice_access_exception",
    "errorcode": "accessexception",
    "message": "Access control exception"
}

The way I am trying to i.e. create the user is as follows:

enter image description here

In the body section I am sending the following data:

  • users[0][username]
  • users[0][email]
  • users[0][lastname]
  • users[0][firstname]
  • users[0][password]

Based on my research, most of the contributors suggested enabling web services, but as mentioned above I have enabled them but the problem persists.

Can someone help me solve the issue here or maybe suggest a way of debugging it?

asha
  • 83
  • 1
  • 9

1 Answers1

0

Fortunately, I managed to solve the issue for both user creation and user enrollment.

Here is a great guide that helped me. In addition, you need to add some additional functions to the web service (roles wary based on what you want to do in Moodle) and also you need to alter the permissions of the new user (again depending on what you want to do)...

asha
  • 83
  • 1
  • 9