{
"basePath": "/",
"swaggerVersion": "1.1",
"apiVersion": "0.1",
"apis": [
{
"operations": [
{
"errorResponses": [
{
"reason": "If the transaction is fully executed and committed on the server, HTTP 200 will be returned.
",
"code": "200"
},
{
"reason": "If the transaction specification is either missing or malformed, the server will respond with HTTP 400.
",
"code": "400"
},
{
"reason": "If the transaction specification contains an unknown collection, the server will respond with HTTP 404.
",
"code": "404"
},
{
"reason": "Exceptions thrown by users will make the server respond with a return code of HTTP 500
",
"code": "500"
}
],
"parameters": [
{
"dataType": "String",
"paramType": "body",
"required": true,
"name": "body",
"description": "Contains the collections and action.
"
}
],
"notes": "
The transaction description must be passed in the body of the POST request.
The following attributes must be specified inside the JSON object:
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/transaction <<EOF\n{ \n \"collections\" : { \n \"write\" : \"products\" \n }, \n \"action\" : \"function () { var db = require('internal').db; db.products.save({}); return db.products.count(); }\" \n}\nEOF\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : 1, \n \"error\" : false, \n \"code\" : 200 \n}\n
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/transaction <<EOF\n{ \n \"collections\" : { \n \"write\" : [ \n \"products\", \n \"materials\" \n ] \n }, \n \"action\" : \"function () {var db = require('internal').db;db.products.save({});db.materials.save({});return 'worked!';}\" \n}\nEOF\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : \"worked!\", \n \"error\" : false, \n \"code\" : 200 \n}\n
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/transaction <<EOF\n{ \n \"collections\" : { \n \"write\" : \"products\" \n }, \n \"action\" : \"function () {var db = require('internal').db;db.products.save({ _key: 'abc'});db.products.save({ _key: 'abc'});}\" \n}\nEOF\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n \"exception\" : \"[ArangoError 1210: unique constraint violated]\", \n \"stacktrace\" : [ \n \"[ArangoError 1210: unique constraint violated]\", \n \" at Error (native)\", \n \" at eval (<anonymous>:1:99)\", \n \" at eval (<anonymous>:1:122)\", \n \" at post_api_transaction (js/actions/api-transaction.js:268:16)\", \n \" at Function.actions.defineHttp.callback (js/actions/api-transaction.js:288:11)\", \n \"\" \n ], \n \"error\" : true, \n \"code\" : 400, \n \"errorNum\" : 1210, \n \"errorMessage\" : \"unique constraint violated\" \n}\n
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/transaction <<EOF\n{ \n \"collections\" : { \n \"read\" : \"products\" \n }, \n \"action\" : \"function () { throw 'doh!'; }\" \n}\nEOF\n\nHTTP/1.1 500 Internal Error\ncontent-type: application/json; charset=utf-8\n\n{ \n \"exception\" : \"doh!\", \n \"error\" : true, \n \"code\" : 500, \n \"errorNum\" : 500, \n \"errorMessage\" : \"An error has occurred during execution: doh!\" \n}\n
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/transaction <<EOF\n{ \n \"collections\" : { \n \"read\" : \"products\" \n }, \n \"action\" : \"function () { return true; }\" \n}\nEOF\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"exception\" : \"[ArangoError 1203: collection not found]\", \n \"stacktrace\" : [ \n \"[ArangoError 1203: collection not found]\", \n \" at Error (native)\", \n \" at post_api_transaction (js/actions/api-transaction.js:268:16)\", \n \" at Function.actions.defineHttp.callback (js/actions/api-transaction.js:288:11)\", \n \"\" \n ], \n \"error\" : true, \n \"code\" : 404, \n \"errorNum\" : 1203, \n \"errorMessage\" : \"collection not found\" \n}\n