Ingest Using MarkLogic REST Client API

The MarkLogic REST Client API is a set of REST endpoints that allow you to interact with MarkLogic.

Before you can ingest, you must already have a DHF project. You can create one with QuickStart or with the Gradle plugin.

When you set up a DHF project, a transform is installed on MarkLogic with the name run-flow, which you can invoke using the REST Client API.

REST Client API Example

This example shows how to use the v1/documents endpoint to insert a document and run an Input Flow against it. The parameters are the following:

  1. transform - the name of the transform. If your flow is written in XQuey, this value must be ml:inputFlow. If it’s written in JavaScript, use ml:sjsInputFlow.
  2. trans:entity-name - the name of the entity to which the input flow belongs.
  3. trans:flow-name - the name of the input flow.
  4. trans:options - [Optional] additional JSON options you can pass to the flow. Must be a JSON object.
  5. trans:job-id - [Optional] a job id, any string is OK. If none is provided then a UUID is generated for you.

XQuery:

curl --anyauth --user admin:admin -T ./my-content -i \
  -X PUT -H "Content-type: application/xml" \
  http://localhost:8010/v1/documents?uri=/shakespeare/plays/a_and_c.xml&transform=ml:inputFlow&trans:entity-name=YourEntityName&trans:flow-name=YourFlowName&trans:options={"your":"options"}&trans:job-id=someString

JavaScript:

curl --anyauth --user admin:admin -T ./my-content -i \
  -X PUT -H "Content-type: application/json" \
  http://localhost:8010/v1/documents?uri=/fascinating-data/structure.json&transform=ml:sjsInputFlow&trans:entity-name=YourEntityName&trans:flow-name=YourFlowName&trans:options={"your":"options"}&trans:job-id=someString