Web-Services allows to integrate Moodle data with another external applications and programming languages through XML or JSON formats. For example, you can export or import Moodle users data with your CRM. In other words, this is an API: REST or SOAP.
moodle-local_wsmanager
lets you easily manage and
test Moodle Web Services instances from one place and much more.
Creating Moodle Web-Services and tuning up the ones is a huge job if you are following a "Moodle way": administrator has to jump between a lot of sections. WSManager has only two sections:
- Dashboard. Global info, settings, docs links and testing tiny service.
- Web Services. Manage all services and its instances: tokens, users, functions.
- Download the plugin zip-file
- Add to your Moodle as administrator
Site administration
(/admin/search.php)Plugins
tabInstall plugins
link (/admin/tool/installaddon/index.php).- Upload
ZIP package
and clickInstall plugin from ZIP file
Web Services Manager allows you to:
- Quickly check status/errors and enable or disable WS globally
- Add a new instance
- Switch REST and SOAP protocols
- Manage Mobile App settings
- Test Web Services through creating a tiny one just to look how does WS works
- Create a new instance
- Manage all of Web Services settings and instances in one window:
- Settings
- Check the info:
Short name
,Time added
- Enable/disable WS
- Change name (if it is custom WS)
Authorised users only
switchCan download files
switchCan upload files
switch
- Check the info:
- Manage Tokens
- View all WS tokens and its options:
- Value
- User
- IP restriction
- Valid until
- Creator
- Create WS tokens
- Delete WS tokens
- View all WS tokens and its options:
- Users (if
Authorised users only
enabled)- View all WS users and options:
- Full name
- IP restriction
- Valid until
- Add WS users
- Delete WS users
- View all WS users and options:
- Functions
- View all WS functions and options:
- Function name
- Function description
- Test/execute function
- Add WS function
- Delete WS function
- View all WS functions and options:
- Settings
As an administrator follow to:
Site administration
(/admin/search.php)Server
tab (/admin/search.php#linkserver)- Find
Web services manager
section. There are two links: Dashboard and Web services
Here you can control common settings of WS status.
If some options are breaking WS work, notification will show an error message with AJAX link to fix it to minimum
default settings to enable Web-Services. If notification message is Web Services are ready to go
means everything
fine.
Error example. Just click on Fix it
and confirm this action.
Moodle Mobile App works with enabled WS and has an own setting to enable/disable. You can switch it here or go to
native Settings
section.
This section is to make a simple test with tiny service and function handler. Web service test client
link is an
internal Moodle plugin to test some simple functions.
Test function
widget allows to test built-in tiny simple function with input data
argument that is returned.
- Click on
Create Test Web Service
button and confirm modal dialog. - New service with test function
local_wsmanager_external_function_test_handle
is created - Fields:
Enabled
- Web-Service enable/disable switcher. For security reason, disable it if unusualWeb Service
nameFunction
nameDescription
Delete
button, here you can delete this WSType
read/writeTesting
button that opens a modal dialog to manage function execution
List of useful links for Moodle Web-Services: documentation, Built-in external functions, Forum etc.
List of exists services with all manage functions
Click on + Add service
link that shows the create form, fill it and save to add the one.
Services divided to Built-in
(Mobile WS and External Plugins WS) and Custom
(created by administrator). Here you can
navigate to a needle service.
Token is a necessary parameter to make a request, this is a hashed unique string. Here administrator can add a new token or delete an exist one.
If the service restricted with Authorised users only
option, administrator can add users to WS.
External function is a handler and main point of request.
Every request has necessary parameters, at least it's a token and function. Every function has own parameters and type.
In the plugin every external function has a manage button Testing
(if WS Tokens are not empty) that shows a dialog
modal, here we can see all information about this function and also make a test/execution request. But be sure before
you execute it that request is fine for you and security. If the type of function is read
- recommended request
method is GET
, if write
- POST
.
Let's take a look at function options
Web Service
name of function WSFunction
nameDescription
Type
:read
/write
- Request
Method
:GET
/POST
Protocol
: list of enabled protocols (at Dashboard)Format
:JSON
/XML
- only forREST
protocol- Service
Token
to use in test request - Function parameters with its info. Fill an own data and data in
Request
widget will be updated on a blur event Request
widget. Here you can see all request info dataExecute
button to send a test request.Response
will be shown above.
- B. Desai: method
add_keys_dynamic
from Stackoverflow
The Moodle WSManager Moodle plugin is licensed under the terms of the GPL-3.0+ license and is available for free.