Loading TOC...

PUT /v1/graphs

Summary

Create or replace quads in the triple store; or create or replace other kinds of triples in a named graph or the default graph; or replace the permissions on 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. When loading quads, this graph overrides any graph URIs in individual quads.
repair? If set to true, data in the request body that cannot be parsed are skipped and parsable triples or quads are inserted. If set to false, data 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 created or replaced. 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 loading semantic data (category=content), set the specified permissions on the graph. For example, perm:editor=update. Valid values: read, update, execute. These roles replace the current permissions on the graph. This parameter can only be used with a default or graph parameter.
Request Headers
Content-Type The MIME type of the data in the request body. When loading semantic data (category=content), use one of the supported RDF formats; for details, see Supported RDF Triple Formats in the Semantic Graph Developer's Guide. If no graph or default is included in the request, the MIME type must be application/trig or application/n-quads. When setting graph permissions (category=permissions), the MIME type must be application/xml or application/json.

Response

Upon success, MarkLogic Server returns status 201 (Created) or status 200 (OK). 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:

A PUT request is functionally equivalent to a DELETE followed by a POST. Supplying an empty graph is equivalent to deleting the graph when loading data that is not in N-Quad or TriG format.

This interface implements the PUT method of the W3C Graph Store HTTP Protocol; for details, see http://www.w3.org/TR/sparql11-http-rdf-update/. Additional capabilities for loading triples are available through the XQuery API and the mlcp command line tool. For details, see Loading Triples in the Semantic Graph Developer's Guide.

Note: Your input data must not be larger than 512M for RDF/XML (MIME type application/rdf+xml) or 64M for all other formats.

NOTE: The collection lexicon must be enabled on your database when using this method. You can check the configuration from the Admin Interface.

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 PUT --data-binary @./example.ttl \
    -H "Content-type: text/turtle" \
    http://localhost:8000/v1/graphs?default

==> The default graph is populated with the input Turtle data. Any previous
    content in the default graph is overwritten. MarkLogic responds with
    output similar to the following:

HTTP/1.1 201 Created
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 PUT --data-binary @./example.ttl \
    -H "Content-type: text/turtle" \
    'http://localhost:8000/v1/graphs?graph=/my/graph&perm:readers=read'

==> The named graph is populated with the input Turtle data. Any previous
    content in the graph is overwritten. The graph permissions grant
    the read capability to users with the "readers" role; any previous 
    graph permissions are overwritten. MarkLogic responds with output
    similar to the following:

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

Example

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

==> Grant users with the "readers" role read access to the graph.
    Any previous graph permissions are overwritten. The graph contents 
    are unchanged. 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
  

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