2.10. Handling errors

The result of any request against the transaction endpoint is streamed back to the client. Therefore, the server does not know whether the request will be successful or not when it sends the HTTP status code.

Because of this, all requests against the transactional endpoint will return 200 or 201 status code, regardless of whether statements were successfully executed. At the end of the response payload, the server includes a list of errors that occurred while executing statements. If the list is empty, the request completed successfully.

If errors occur while executing statements, the server will roll back the transaction.

In this example, we send an invalid statement to the server in order to demonstrate error handling.

For more information on the status codes, see Neo4j Status Codes v3.5.

Example request

{
  "statements" : [ {
    "statement" : "This is not a valid Cypher Statement."
  } ]
}

Example response

{
  "results" : [ ],
  "errors" : [ {
    "code" : "Neo.ClientError.Statement.SyntaxError",
    "message" : "Invalid input 'T': expected <init> (line 1, column 1 (offset: 0))\n\"This is not a valid Cypher Statement.\"\n ^"
  } ]
}