Can't sucessfully use the Neo4j API to send and execute a Cypher query

I have sent the following API request to Neo4j

http://xxx.xxx.xxx.xxx:7474/db/Box Access/tx/commit

with the following very simple body

{
statements: [
{
statement: "RETURN 1"
}
]
}

And get this response no matter what I try. What am I missing?

{
"results": ,
"errors": [
{
"code": "Neo.ClientError.Request.InvalidFormat",
"message": "Could not parse the incoming JSON"
}
]
}

At first glance it looks like you're not sending valid JSON in the request body.

Try

{
  "statements": [
    {
      "statement": "RETURN 1"
    }
  ]
}

Thanks. but I mistakenly sent our latest try variation. Among other attempts, we did structure the JSON exactly as you suggested and received the very same error message. To confirm that, I just tried it again with your suggested JSON with no change in the error.

@bvasu

What version of Neo4j?

how are you submitting? for example is this via curl or postman ? Have you defined the Content-Type: application/json

Actually we are using a Make integration eventually but we are using Postman to test the API call. And, yes, Content-Type is set to application/json.

@bvasu

and do you have Neo4j version details? is this version 5.x? 4.x? or ??

Is that space in the database name? So you're trying to connect to

http://xxx.xxx.xxx.xxx:7474/db/Box Access/tx/commit rather than http://xxx.xxx.xxx.xxx:7474/db/BoxAccess/tx/commit ?

fwiw this works via curl

 curl -H "Content-Type: application/json" -d "{   \"statements\": [   {   \"statement\": \"RETURN 1\"  } ] }"  http://localhost:7474/db/neo4j/tx/commit

and returns

{"results":[{"columns":["1"],"data":[{"row":[1],"meta":[null]}]}],"errors":[],"lastBookmarks":["FB:kcwQwmlUd/XlSAaazhJtAnHT+m+Q"]}

and with Neo4j 5.23

This seems to work for me, using "neo4j" as the database, and basic authorization.

{
    "statements": [
        {
            "statement": "RETURN 1"
        }
    ]
}

1 Like

Yes, but what is not clear to me is how to distinguish in an API call between the database "neo4j" and the project databases within that "neo4j" database such as "Box Access.".

@bvasu

do you have a database named Box Access? Does this name appear in cypher statment show databases?

and if you do have you tried a request to

http://xxx.xxx.xxx.xxx:7474/db/Box%20Access/tx/commit

and whereby %20 is the encoding for a whitespace character

Neo4j version is 5.x

@bvasu

5.x? do u know what the x is? 5.24? 5.20? etc. why? because if it is a bug it would be great to test against the same version you are using.

if you run the curl command described at

does it error? does it succeed?

We are using Linux Neo4j 5.24.0 and using your curl our return is {"results":,"errors":[{"code":"Neo.ClientError.Request.InvalidFormat","message":"Could not parse the incoming JSON"}]}