neo4j-rest-client icon indicating copy to clipboard operation
neo4j-rest-client copied to clipboard

Create doesn't work with lists

Open Yorkst opened this issue 8 years ago • 4 comments

db.nodes.create(parameter=[]) fails with "Bad Request. Bad request syntax or unsupported method."

Yorkst avatar Oct 07 '16 18:10 Yorkst

That's because the REST API doesn't support storing objects as properties values other than plain numbers, booleans, and strings. Plus, Neo4j doesn't store either null or empty property values.

versae avatar Oct 10 '16 06:10 versae

My neo4j sure does

create (t:Test {data: []})

match(t:Test) return t.data

Neo4j

Yorkst avatar Oct 10 '16 06:10 Yorkst

Does that work through the REST API using the API methods and not Cypher queries? I'll double check.

versae avatar Oct 10 '16 06:10 versae

Just tried with 2.2.10 and 2.3.7 and got this:

$ curl -H "Content-Type: application/json" -X POST http://localhost:7474/db/data/node -d '{"prop": []}'
{
  "message" : "Unable to set property 'prop' to an empty array, because, since there are no values of any type in it, and no pre-existing collection to infer type from, it is not possible to determine what type of array to store.",
  "exception" : "PropertyValueException",
  "fullname" : "org.neo4j.server.rest.web.PropertyValueException",
  "stackTrace" : [ "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperty(PropertySettingStrategy.java:120)", "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperties(PropertySettingStrategy.java:88)", "org.neo4j.server.rest.web.DatabaseActions.createNode(DatabaseActions.java:205)", "org.neo4j.server.rest.web.RestfulGraphDatabase.createNode(RestfulGraphDatabase.java:252)", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)", "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)", "java.lang.Thread.run(Thread.java:745)" ],
  "errors" : [ {
    "message" : "Unable to set property 'prop' to an empty array, because, since there are no values of any type in it, and no pre-existing collection to infer type from, it is not possible to determine what type of array to store.",
    "code" : "Neo.ClientError.Statement.InvalidArguments"
  } ]
}

versae avatar Oct 10 '16 07:10 versae