Error handling

The result of any request to the HTTP API is streamed back to the client as received from the underlying Neo4j server. The server does not know whether the request will be successful or not when it sends the HTTP status code. Because of this, all API requests return a 200/201 status code, regardless of whether the statements were successfully executed. The only exception is authentication errors, which result in a 301 status code.

At the end of the response payload, the server includes a list of errors that occurred while executing statements. An empty list means the request completed successfully.

Example 1. Send an invalid Cypher statement

Example request

POST  http://localhost:7474/db/neo4j/tx/commit
Accept: application/json;charset=UTF-8
Content-Type: application/json
{
  "statements": [
    { "statement": "This is not a valid Cypher Statement and will raise an error." }
  ]
}

Example response

200: OK
Content-Type: application/json;charset=utf-8
{
  "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 ^"
  } ]
}

For more information on error codes the server may raise, see Neo4j Status Codes.