0

I have my java app using Neo4j API. Everything works fine, except when I pass by args the path of my file to process.

This is the code working fine:

session.run("call 
apoc.xml.import(\"http://www.example.com/myfile.xml\") YIELD node
RETURN node");

Since I need to create an app which is general purpose, I need to pass the file from the user input. When I pass by args the URL, I got the error because there must be something wrong in the string.

This is the code with problem:

session.run("call apoc.xml.import(\" "  + file  + " \" ) YIELD node RETURN node");

where file is the variable containing http://www.example.com/myfile.xml

Am I doing something wrong?

Wall
  • 293
  • 3
  • 13

1 Answers1

0

Try to pass the variable through the parameters:

Map<String, Object> params = new HashMap<>();
params.put( "file", file );
session.run("call apoc.xml.import($file) YIELD node RETURN node", params);

[ https://neo4j.com/docs/java-reference/3.4/tutorials-java-embedded/#tutorials-cypher-parameters-java ]

stdob--
  • 28,222
  • 5
  • 58
  • 73