cancel
Showing results for 
Search instead for 
Did you mean: 

Transactional Cypher HTTP endpoint cause error when using :

gleithoernchen
Node Link

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 <init> (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 <init> (line 1, column 1 (offset: 0))\r\n\":USE Nemo13\"\r\n ^"}]}

 

4 REPLIES 4

glilienfield
Ninja
Ninja

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

gleithoernchen
Node Link

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. 

gleithoernchen
Node Link

Yes 🙂 That solved the issue. Many thanks

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.