cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Yet another REST API question - can't call apoc.load.json within FOREACH

Trying to build an employee database. Every employee has a unique employee ID. I have a list in CSV format which I load to create my Employee nodes with an employeeId property set. This gives me a good start. Unfortunately, that is all the info I have at the moment, and would like to set additional properties on the nodes. Things like first and last name. Luckily, the company has a REST API. I can easily query the end point by typing in employeeId to get the resulting JSON. For example, https://rest.api/?query=1234 Then UNWIND as needed and set some properties on the nodes. The endpoint will accept more than one employeeId but has a limit of 1000, and I have over 360K users to input and update.

I first tried to get a list of employeeId from a MATCH query, and then run a FOREACH command. The problem with that is that I get an error stating that you can't call apoc.load.json from within the FOREACH command. Does anybody have a suggested way doing this using cypher?

I can get the needed data using a table dump to solve my problem, but I really would like a way to do this using cypher/neo4j only. Thoughts?

1 REPLY 1

Is your foreach calling the endpoint for each individual employeeId in your match result? If so, could you use unwind instead?