Transactional Cypher HTTP endpoint cause error when using :

Hi,

I need to create and use a database via the http endpoint. creating works but it still uses the default database (neo4j). When I try to use ":USE NAME" via http it complains that a ":" is not valid. But I need to create many different databases and use them... any idea how to solve this? Maybe I have the wrong url?

My url is:

"http://localhost:11006/db/data/transaction/commit"

That is the Error Message:

{"results"=>, "errors"=>[{"code"=>"Neo.ClientError.Statement.SyntaxError", "message"=>"Invalid input ':': expected (line 1, column 1 (offset: 0))\r\n\":USE Nemo13\"\r\n ^"}]}

That is the part of my script:

#creates Database in neo4j, if not exists --> works
caseName = currentCase.getName
payload = { "statements": [{ "statement": "CREATE DATABASE #{caseName}" }]}
returnValue = Client.post(url, headers, payload, use_ssl)

#uses that database --> error
string = ":USE #{caseName}"
puts string # Nemo13
payload = { "statements": [{ "statement": "#{string}"}]}
returnValue = Client.post(url, headers, payload, use_ssl)
puts returnValue # {"results"=>, "errors"=>[{"code"=>"Neo.ClientError.Statement.SyntaxError", "message"=>"Invalid input ':': expected (line 1, column 1 (offset: 0))\r\n\":USE Nemo13\"\r\n ^"}]}

try without the colon. I was able to do so in browser.

Yes :slightly_smiling_face: That solved the issue. Many thanks

that did not work. now i get this error message:

{"results"=>, "errors"=>[{"code"=>"Neo.ClientError.Statement.SyntaxError", "message"=>"Query cannot conclude with USE GRAPH (must be a RETURN clause, an update clause, a unit subquery call, or a procedure call with no YIELD) (line 1, column 1 (offset: 0))\r\n\"USE Nemo13\"\r\n ^"}]}

but thanks anyway

It looks like you are using the statement by itself. Try inserting it at the beginning of each query to specify the database to use for that query.