You're providing a directory outside the import directory defined into `dbms.directories.import`

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

Settings: apoc

apoc.import.file.enabled=true
apoc.import.file.use_neo4j_config=true

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

Hi @Mariana ,

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

Choose "Copy url to clipboard" and use that instead.

Best,
ABK

I don' have the file in that place, can you please tell me how do I put it there?

Two options:

On the top-right corner of the project, use the "Add" button, which reveals a drop-down that includes an option to add a file...
image

Alternatively, drag-and-drop the file on the project name in the "Projects" sidebar...

image

-ABK

When I do that, the file goes to the folder but does not appear on here.


Hm. :thinking:

Perhaps a refresh problem. Try restarting Neo4j Desktop.

I already try and nothing seems to work. I think I'm going to desinstall Neo4j and try again.

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 it worked!
Thank you!

1 Like

Facing same issue with Neo4j(4.3.1) and apoc(4.3.0.4) in neo4j Desktop

Also added the apoc.conf file in conf location
tried 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

tried this CALL apoc.load.xml("file:///books.xml")
YIELD value
RETURN value

Anyone has any solution for this???

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'}], [], {});

I hope this helps!!