CRUD

Yep that's Create, Read, Update, and Delete. We use the term Insert instead of Create but that doesn't keep us from saying CRUD for fun. MarkLogic provides a simple API for CRUD.

To insert a document, send a PUT request to the /documents endpoint with the document URI as a parameter. The format parameter specifies the documents format. For example, to store a JSON document with URI /afternoon-drink.json:

where you get myhost:port and your username and password from your database administrator.

If you haven't seen the curl tool before, it's a popular command line http client, that is ideal for playing with REST apis. If you don't have a copy, look here.

curl supports specifying your credentials on the command line with a --user username:password flag. Alternatively, you can store these in your .curlrc file. This and additional details on curl can be found in its manual page.

To get the document back:

If you'd rather have MarkLogic automatically generate a unique URI for you, you can send the original document via a POST, along with an extension parameter to indicate the format.

(The MarkLogic response includes a Location header that contains the URI of the new document.)

To update the existing document, send another PUT request:

And to delete the document, send a DELETE request:

The REST API provides additional functionality related to CRUD, including

These techniques are covered in the REST API Developers Guide and the Document Management endpoint reference.

Basic Concepts

Search and Query APIs

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.