Owen Barritt
Lead maintainer
REST webservice protocol based on the standard core REST webservice, but with added support for JSON & XML payloads and supports using HTTP ACCEPTS headers for determining response format.
Simply place the plugin files in ./webservice/restjson
Should be enabled and setup in the standard way for webservices. See https://docs.moodle.org/29/en/Using_web_services for details.
The protocol can be called in the usual way for webservices with either JSON or XML data specified in content type (also backward compatible with current REST webservice so will also accept POST form data)
e.g. for a JSON payload
curl -H "Content-Type: application/json" -X POST -d '{"wsfunction":"...", "wstoken":"...",request object}' http://moodle.url/path/to/webservice/restjson/server.php
Parameters such as wsfunction and wstoken can also still be specified in the URL if required
curl -H "Content-Type: application/json" -X POST -d '{request object}' http://moodle.url/path/to/webservice/restjson/server.php?wsfunction=...&wstoken=...
Response format can also be set to XML or JSON by setting the accept HTTP header e.g. to send in JSON and receive in XML (by default same format is used to return as originally received) you could use:
curl -H "Content-Type: application/json" -H "Accept: application/xml"-X POST -d '{request object}' http://moodle.url/path/to/webservice/restjson/server.php?wsfunction=...&wstoken=...