Loading TOC...

POST /v1/graphs

Summary

Merge quads into the triple store, or merge other types of triples into a named graph or the default graph.

URL Parameters
database? Perform this operation on the named content database instead of the default content database associated with the REST API instance. Using an alternative database requires the "eval-in" privilege; for details, see Security Requirements in the REST Application Developer's Guide.
graph? The URI of the named graph to modify. You cannot use this parameter with the default parameter. When loading quads, this graph overrides any graph URIs in the input quads.
default? Indicates the request should modify the default graph. This parameter accepts no value. You cannot use this parameter with the graph parameter. If you include this parameter when loading quads, the default graph overrides any graph URIs in the input quads.
repair? If set to true, triples in the request body that cannot be parsed are skipped, and parsable triples are inserted. If set to false, triples in the request body that cannot be parsed cause all the data in the request to be rejected. Default: false.
category? The category of data to be modified. Valid categories: content (default), metadata, permissions. The metadata and permissions values are synonymous. This parameter can only be used with a default or graph parameter.
txid? The transaction identifier of the multi-statement transaction in which to service this request. Use the /transactions service to create and manage multi-statement transactions.
perm:{role}* When updating semantic data (category=content), add the specified permissions to the graph. For example, perm:editor=update. Valid values: read, update, execute. Only the named role is changed. This parameter can only be used when the request includes content and when the default or graph parameter is present. See the Usage Notes for deatils.
Request Headers
Content-Type The MIME type of the data in the request body. For details, see Supported RDF Triple Formats in the Semantics Developer's Guide. When updating content, if no graph or default parameter is included in the request, the MIME type must be application/trig or application/n-quads.

Response

Upon success, MarkLogic Server returns status 201 (Created) or status 204 (Updated). If there are errors in the payload, the response body contains further information about the errors. If the request body is in an unsupported format, MarkLogic Server returns status 415 (Unsupported Media Type).

Required Privileges

This operation requires the rest-writer role, or the following privilege:

http://marklogic.com/xdmp/privileges/rest-writer

Usage Notes

You can use this method in the following ways:

If you use this method to merge data into a graph that does not exist, the graph will be created.

When used with the default or graph parameters, this interface implements the POST method of the W3C Graph Store HTTP Protocol; for details, see http://www.w3.org/TR/sparql11-http-rdf-update/.

Supplying an empty graph is a no-op if the input data MIME type is not application/n-quads or application/trig.

The collection lexicon must be enabled on the database before using this method. You can enable the collection lexicon from the Admin Interface.

Additional capabilities are available through the XQuery API and the mlcp command line tool. For details, see Updating Triples in the Semantics Developer's Guide.

See Also

Example

NOTE: Be sure to use --data-binary rather than -d if extracting
the request body from a file with curl, as shown below.

$ curl --anyauth --user user:password -i -X POST \
    --data-binary @./example.nq -H "Content-type: application/n-quads" \
    http://localhost:8000/v1/graphs

==> The N-Quad data in example.nq is merged into the graphs specified
    by each quad. MarkLogic Server responds with output similar to 
    the following:

HTTP/1.1 204 Updated
Location:
Server: MarkLogic
Content-Length: 0
Connection: Keep-Alive
Keep-Alive: timeout=5
  

Example

NOTE: Be sure to use --data-binary rather than -d if extracting
the request body from a file with curl, as shown below.

$ curl --anyauth --user user:password -i -X POST \
    --data-binary @./example.ttl -H "Content-type: text/turtle" \
    'http://localhost:8000/v1/graphs?graph=/my/named/graph&perm:myrole=read'

==> The Turtle data in example.ttl is merged into the graph with the
    URI /my/named/graph and the permissions for the graph are updated.
    MarkLogic Server responds with output similar to the following:

HTTP/1.1 204 Updated
Location:
Server: MarkLogic
Content-Length: 0
Connection: Keep-Alive
Keep-Alive: timeout=5
  

Example

NOTE: Be sure to use --data-binary rather than -d if extracting
the request body from a file with curl, as shown below.

$ curl --anyauth --user user:password -i -X POST \
    --data-binary @./example.nq -H "Content-type: application/n-quads" \
    http://localhost:8000/v1/graphs

==> The N-Quads in the input file are added to the graphs specified in
    the data. MarkLogic responds with output similar to the following:

HTTP/1.1 204 Updated
Server: MarkLogic
Content-Length: 0
Connection: Keep-Alive
Keep-Alive: timeout=5
  

Example

$ curl --anyauth --user user:password -i -X POST \
    -d '{"permissions":[{"role-name":"readers","capabilities":["read"]}]}' \
    -H "Content-type: application/json" \
    'http://localhost:8000/v1/graphs?default&category=permissions'

==> The permissions specified in the request are added to the permissions
    of the default graph. MarkLogic responds with output similar to the 
    following:

HTTP/1.1 204 Updated
Server: MarkLogic
Content-Length: 0
Connection: Keep-Alive
Keep-Alive: timeout=5
  

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy