Hi! I'm trying to import an json file to neo4j, but it shows this error. I already changed the settings and imported the file to the right location. Can please someone help? Thank you in advance.
Cypher statement: //Load_JSON_Country
CALL apoc.load.json("file:///countries.json")
YIELD value
Error: Failed to invoke procedure apoc.load.json : Caused by: java.io.IOException: You're providing a directory outside the import directory defined into dbms.directories.import
Could you share some details about which version of Neo4j you're using, on what OS platform, and how you're running it (Desktop, Docker, something else).
Best,
ABK
ps. This is a cross-post from StackOverflow, correct?
Hi!
I'm using Neo4j Desktop, version 1.4.7 on Windows x64. I don't know if the error may be related to the number of databases I already have... At the moment I have 10 and I am using the free version.
And yes, I put the same post on StackOverflow.
Thank you!
Mariana
OK. It is most likely that you are running into a challenge with using the file: URI scheme on Windows. I'm not on Windows at the moment, but an alternative is to ignore the file: scheme and use http: instead. How?
Neo4j Desktop hosts project files with a local http server. In Desktop, click on the ... menu next to a filename, which will reveal something like
I change the settings to this:
dbms.directories.import = C:/
apoc.import.file.enabled=true
dbms.security.procedures.unrestricted=jwt.security.,apoc.,gds.,n10s.
And then, the path for this:
//Load_JSON_Country
CALL apoc.load.json("/Users/.Neo4jDesktop/relate-data/dbmss/dbms-1f5f63ad-bba8-4673-8d16-2a3bd7299f65/import/countries.json")
YIELD value
RETURN value
And then, the path for this:
//Load_JSON_Country
CALL apoc.load.json("/Users/.Neo4jDesktop/relate-data/dbmss/dbms-1f5f63ad-bba8-4673-8d16-2a3bd7299f65/import/countries.json")
YIELD value
RETURN value
For windows, the simplest thing to do is to change the number of forward slashes to TWO forward slashes if you want to point to the default import directory. All the examples I followed had the following
# Either this with one forward slash
call apoc.import.csv([{fileName: 'file:/test_import.csv'}], [], {});
# Or this, with three forward slashes
call apoc.import.csv([{fileName: 'file:///test_import.csv'}], [], {});
# Neither worked for me and both (1 and 3) gave me the following error messages
Failed to invoke procedure apoc.import.csv: Caused by: java.io.IOException: Youre providing a directory outside the import directory defined into dbms.directories.import
# Two slashes worked
call apoc.import.csv([{fileName: 'file://test_export.csv'}], [], {});