Enabling the web services in moodle requires you to have administrator access.
For a detailed overview go to: Site Administration > Server > Web Services > Overview

  1. Enable web services
    Web services must be enabled in Advanced features.
  2. Enable protocols
    At least one protocol should be enabled. For security reasons, only protocols that are to be used should be enabled.
  3. Create a specific user
    A web services user is required to represent the system controlling Moodle.
  4. Check user capability
    The user should have appropriate capabilities according to the protocols used, for example webservice/rest:use, webservice/soap:use. To achieve this, create a web services role with protocol capabilities allowed and assign it to the web services user as a system role.
  5. Select a service
    A service is a set of web service functions. You will allow the user to access to a new service. On the Add service page check 'Enable' and 'Authorised users' options. Select 'No required capability'.
  6. Add functions
    Select required functions for the newly created service.
  7. Select a specific user
    Add the web services user as an authorized user.
  8. Create a token for a user
    Create a token for the web services user.
  9. Enable developer documentation
    Detailed web services documentation is available for enabled protocols.
  10. Test the service
    Simulate external access to the service using the web service test client. Use an enabled protocol with token authentication.

Testing Live Environments
The functions that you test WILL BE EXECUTED, so be careful what you choose to test

Check User Capability

Step 4 requires you to create a role go to: Site Administration > Users > Define Roles

  1. Select Archetype 
    Choose Authenticated User
  2. Select Capabilities 
    Choose the Web Services it needs to be able to access.

  3. Click Create Role

Select a service and add functions

Step 5 and 6 require you to add a service and configure the functions.
Go to: Site Administration > Server Web Services > External Services.

  1. At the bottom click Add
  2. Fill in the external service form

  3. Click Add Service
  4. Click Add Functions
  5. Select Appropriate Functions from the dropdown

  6. Click Add Functions

Select a specific user

Step 7 requires you to authorize a user for api access.
Go to: Site Administration > Server Web Services > External Services.

  1. Click Authorized Users
  2. Move the API user to the left column

  3. Check the capabilities for the user at the bottom, it will list add the missing capabilities.

  4. Go back to the role and all the missing capabilities. 

Create a token for the user

Step 8 requires you to create a token for the user.
Go to: Site Administration > Server Web Services > Manage Tokens.

  1. Click Create Token
  2. Fill out the form

  3. Click Save Changes to create the token.

The API has now been setup, all that is left is setting up Power BI to start importing data. 

    I like to see who's visiting my website, do you accept?
    Do you want to accept tracking cookies?