Neo4j CALL {} IN TRANSACTIONS Does Not Work in Neo4j HTTP API

According to this https://neo4j.com/docs/http-api/current/transactions/, neo4j transactions cannot be used in explicit transactions and need to be sent as implicit transactions.

However, after following the instructions I still get the same error. I'm using neo4j version 4.4.3 and running this first to create a transaction.

curl --location 'http://localhost:7474/db/data/transaction/' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json; charset=UTF-8' \

this returns the transaction_number to use in the subsequent query. (this is for making the request 'implicit')

curl --location 'http://localhost:7474/db/data/transaction/{transaction_number}' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json; charset=UTF-8' \
--data '{
  "statements": [
    {
      "statement": "LOAD CSV WITH HEADERS FROM 'file.csv' AS row CALL {with row MERGE (movie:Movies {orderid: row.orderid}) SET movie.name =row.name } IN TRANSACTIONS OF 1000 ROWS"
    }
  ]
}
'

The error after running the second api call:

"message": "A query with 'CALL { ... } IN TRANSACTIONS' can only be executed in an implicit transaction, but tried to execute in an explicit transaction."

The query is simplified for the sake of this question. I've also tried calling neo4j http API with /transaction/commit endpoint but that also throws the same error. Not sure if it's due to versions but the documentation says 5.x. Is there a way to execute implicit transactions as part of neo4j http api calls? My environment limits my options to use neo4j driver as I think all of this would be much easier via driver.

removing the "IN TRANSACTIONS' make it work but i need to write large volume of data and need it to make it more scalable.

Try using POST http://localhost:7474/db/DB_NAME/tx/commit as the endpoint . This is used for implicit transactions. Replace DB_NAME with the name of your database in neo4j.

The example you gave above is an explicit transactions and CALL IN is not supported for those.

As i said in my original question , i've already tried this and got the same error but let me copy/paste more details here.

The first curl request returns this response. @jon.giffard
{ "results": [], "errors": [], "commit": "http://localhost:7474/db/data/transaction/50/commit", "transaction": { "expires": "Fri, 1 Nov 2024 17:02:56 GMT" } }

however, when i try to make another curl request with that transaction number to the same endpoint, i get the same error.

http://localhost:7474/db/data/transaction/50/commit

"message": "A query with 'CALL { ... } IN TRANSACTIONS' can only be executed in an implicit transaction, but tried to execute in an explicit transaction."

also, if i try to make another request right after this, it throws a different error. I am not sure what the life span of a new transaction is but it may be rolling it back right after it throws an error?

        "message": "Unrecognized transaction id. Transaction may have timed out and been rolled back."

Why are you including the TX ID? You don't need this for implicit transactions.

Literally, do a POST request to http://localhost:7474/db/DB_NAME/tx/commit

Here's the curl statement i just ran with my local installation of Neo4j using the db Neo4j.

curl --location 'http://127.0.0.1:7474/db/neo4j/tx/commit' \
--header 'Content-Type: application/json' \
-u neo4j:password \
--data '{
  "statements": [
    {
      "statement": "MATCH (n) RETURN n"
    }
  ]
}'

Thanks for your response. Could this be a version thing? @jon.giffard.

I still get the same error, i can make sample queries easily (like your example) if I don't use CALL {} IN transactions. Maybe try running a query with CALL {} IN TRANSACTIONS

literally just calling this;
http://localhost:7474/db/neo4j/tx/commit

the response:

{
    "results": [],
    "errors": [
        {
            "code": "Neo.DatabaseError.Statement.ExecutionFailed",
            "message": "A query with 'CALL { ... } IN TRANSACTIONS' can only be executed in an implicit transaction, but tried to execute in an explicit transaction."
        }
    ]

my actual request including the query - maybe something with loading csv causes this.


curl --location 'http://localhost:7474/db/neo4j/tx/commit' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json; charset=UTF-8' \
--data '{
  "statements": [
    {
      "statement": "LOAD CSV WITH HEADERS FROM 'file.csv' AS row CALL {with row MERGE (movie:Movies {orderid: row.orderid}) SET movie.name =row.name } IN TRANSACTIONS OF 1000 ROWS"
    },

'

Possibly could a be version difference between 4 and 5. The docs link for v4 is here:- Begin and commit a transaction in one request - HTTP API

I don't think there's a way to do this in 4.x versions. I've tried all the possible combinations in the docs... I wish the docs were more explanatory for showing whether it's feasible or not in different versions. I cannot upgrade it to 5.x since that's a bigger effort but i will use periodic commit instead since that's supported in neo4j rest api 4.x.

It'll be less performant compared call{} in transactions but seems like there's no other way.

I'll pull down a 4.x docker image and give this a try next week. Which 4.x are you running?

4.4.3. I can use CALL{} operations and even use IN TRANSACTIONS with auto: feature in browser but not in http request