{
"basePath": "/",
"swaggerVersion": "1.1",
"apiVersion": "0.1",
"apis": [
{
"operations": [
{
"errorResponses": [
{
"reason": "is returned if all documents could be imported successfully. ",
"code": "201"
},
{
"reason": "is returned if type contains an invalid value, no collection is specified, the documents are incorrectly encoded, or the request is malformed. ",
"code": "400"
},
{
"reason": "is returned if collection or the _from or _to attributes of an imported edge refer to an unknown collection. ",
"code": "404"
},
{
"reason": "is returned if the import would trigger a unique key violation and complete is set to true. ",
"code": "409"
},
{
"reason": "is returned if the server cannot auto-generate a document key (out of keys error) for a document with no user-defined key. ",
"code": "500"
}
],
"parameters": [
{
"dataType": "String",
"paramType": "body",
"required": "true",
"name": "documents",
"description": "The body must either be a JSON-encoded list of documents or a string with multiple JSON documents separated by newlines. "
},
{
"dataType": "String",
"paramType": "query",
"required": "True",
"name": "type",
"description": "Determines how the body of the request will be interpreted. type can have the following values: "
},
{
"dataType": "String",
"paramType": "query",
"required": "True",
"name": "collection",
"description": "The collection name. "
},
{
"dataType": "Boolean",
"paramType": "query",
"name": "createCollection",
"description": "If this parameter has a value of true or yes, then the collection is created if it does not yet exist. Other values will be ignored so the collection must be present for the operation to succeed. "
},
{
"dataType": "Boolean",
"paramType": "query",
"name": "waitForSync",
"description": "Wait until documents have been synced to disk before returning. "
},
{
"dataType": "Boolean",
"paramType": "query",
"name": "complete",
"description": "If set to true or yes, it will make the whole import fail if any error occurs. Otherwise the import will continue even if some documents cannot be imported. "
},
{
"dataType": "Boolean",
"paramType": "query",
"name": "details",
"description": "If set to true or yes, the result will include an attribute details with details about documents that could not be imported. "
}
],
"notes": "Creates documents in the collection identified by collection-name. The JSON representations of the documents must be passed as the body of the POST request. The request body can either consist of multiple lines, with each line being a single stand-alone JSON document, or a JSON list.
The response is a JSON object with the following attributes:
- created: number of documents imported.
- errors: number of documents that were not imported due to an error.
- empty: number of empty lines found in the input (will only contain a value greater zero for types documents or auto).
- details: if URL parameter details is set to true, the result will contain a details attribute which is a list with more detailed information about which documents could not be inserted.
",
"summary": "imports documents from JSON",
"httpMethod": "POST",
"examples": "Importing documents with heterogenous attributes from a JSON list:
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products&type=list\n[{\"_key\":\"abc\",\"value1\":25,\"value2\":\"test\",\"allowed\":true},{\"_key\":\"foo\",\"name\":\"baz\"},{\"name\":{\"detailed\":\"detailed name\",\"short\":\"short name\"}}]\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 3, \n \"errors\" : 0, \n \"empty\" : 0 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products&type=documents\n{ \"_key\": \"abc\", \"value1\": 25, \"value2\": \"test\", \"allowed\": true }\n{ \"_key\": \"foo\", \"name\": \"baz\" }\n\n{ \"name\": { \"detailed\": \"detailed name\", \"short\": \"short name\" } }\n\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 3, \n \"errors\" : 0, \n \"empty\" : 1 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products&type=auto\n[{\"_key\":\"abc\",\"value1\":25,\"value2\":\"test\",\"allowed\":true},{\"_key\":\"foo\",\"name\":\"baz\"},{\"name\":{\"detailed\":\"detailed name\",\"short\":\"short name\"}}]\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 3, \n \"errors\" : 0, \n \"empty\" : 0 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products&createCollection=true&type=list\n[{\"id\":\"12553\",\"active\":true},{\"id\":\"4433\",\"active\":false},{\"id\":\"55932\",\"count\":4334}]\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 3, \n \"errors\" : 0, \n \"empty\" : 0 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=links&type=documents\n{ \"_from\": \"products/123\", \"_to\": \"products/234\" }\n{ \"_from\": \"products/332\", \"_to\": \"products/abc\", \"name\": \"other name\" }\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 2, \n \"errors\" : 0, \n \"empty\" : 0 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=links&type=list&details=true\n[{\"name\":\"some name\"}]\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 0, \n \"errors\" : 1, \n \"empty\" : 0, \n \"details\" : [ \n \"at position 1: missing '_from' or '_to' attribute\" \n ] \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products&type=documents&details=true\n{ \"_key\": \"abc\", \"value1\": 25, \"value2\": \"test\" }\n{ \"_key\": \"abc\", \"value1\": \"bar\", \"value2\": \"baz\" }\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 1, \n \"errors\" : 1, \n \"empty\" : 0, \n \"details\" : [ \n \"at position 2: creating document failed with error 'unique constraint violated',...\" \n ] \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products&type=documents&complete=true\n{ \"_key\": \"abc\", \"value1\": 25, \"value2\": \"test\" }\n{ \"_key\": \"abc\", \"value1\": \"bar\", \"value2\": \"baz\" }\n\nHTTP/1.1 409 Conflict\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"cannot create document, unique constraint violated\", \n \"code\" : 409, \n \"errorNum\" : 1210 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products&type=documents\n{ \"name\": \"test\" }\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"collection 'products' not found\", \n \"code\" : 404, \n \"errorNum\" : 1203 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products&type=list\n{ }\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"expecting a JSON list in the request\", \n \"code\" : 400, \n \"errorNum\" : 400 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products\n[ \"_key\", \"value1\", \"value2\" ]\n[ \"abc\", 25, \"test\" ]\n\n[ \"foo\", \"bar\", \"baz\" ]\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 2, \n \"errors\" : 0, \n \"empty\" : 1 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products&createCollection=true\n[ \"value1\", \"value2\" ]\n[ 1234, null ]\n[ \"foo\", \"bar\" ]\n[ 534.55, true ]\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 3, \n \"errors\" : 0, \n \"empty\" : 0 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=links\n[ \"_from\", \"_to\", \"name\" ]\n[ \"products/123\", \"products/234\", \"some name\" ]\n[ \"products/332\", \"products/abc\", \"other name\" ]\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 2, \n \"errors\" : 0, \n \"empty\" : 0 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=links&details=true\n[ \"name\" ]\n[ \"some name\" ]\n[ \"other name\" ]\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 0, \n \"errors\" : 2, \n \"empty\" : 0, \n \"details\" : [ \n \"at position 1: missing '_from' or '_to' attribute\", \n \"at position 2: missing '_from' or '_to' attribute\" \n ] \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products&details=true\n[ \"_key\", \"value1\", \"value2\" ]\n[ \"abc\", 25, \"test\" ]\n[ \"abc\", \"bar\", \"baz\" ]\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"created\" : 1, \n \"errors\" : 1, \n \"empty\" : 0, \n \"details\" : [ \n \"at position 2: creating document failed with error 'unique constraint violated',...\" \n ] \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products&complete=true\n[ \"_key\", \"value1\", \"value2\" ]\n[ \"abc\", 25, \"test\" ]\n[ \"abc\", \"bar\", \"baz\" ]\n\nHTTP/1.1 409 Conflict\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"cannot create document, unique constraint violated\", \n \"code\" : 409, \n \"errorNum\" : 1210 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products\n[ \"_key\", \"value1\", \"value2\" ]\n[ \"abc\", 25, \"test\" ]\n[ \"foo\", \"bar\", \"baz\" ]\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"collection 'products' not found\", \n \"code\" : 404, \n \"errorNum\" : 1203 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/import?collection=products\n{ \"_key\": \"foo\", \"value1\": \"bar\" }\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"no JSON list found in second line\", \n \"code\" : 400, \n \"errorNum\" : 400 \n}\n\n