Administering your server using ReST
26 April 2016 06:36 PM
Marklogic has shipped with a ReST API since MarkLogic 7.
In MarkLogic 8 the ReST API was vastly expanded, allowing ways for MarkLogic Database administrators to manage almost all common MarkLogic administration tasks over an HTTP connection to MarkLogic's ReST endpoints.
This Knowledgebase article will cover some examples of common administration tasks and will show some working examples to give you a taste of what can be done if you're using the latest version of MarkLogic Server.
While there are a significant number of examples throughout our extensive documentation in this area, many of these make use of CuRL. In this Knowledgebase article, we're going to use XQuery calls to demonstrate how the payloads are structured.
Creating a backup using a call to the ReST API (XQuery)
In the example code below, we demonstrate a call that will perform a backup of the Documents forest which places the backup in the /tmp directory.
Running the query in the above code example will return a response (in JSON format) containing a job ID for the requested task:
The next example will demonstrate a status check for a given job ID
Query the status of an active or recent job
The above query will return a response that would look like this:
Further reading on the MarkLogic ReST API: