Hi Graphista and other Java gurus,
I have changed my code according to answer given and after inspecting the example provided by neo4j, but still to no avail. So please, could anyone help me with this???
I have a java program which connects to a Neo4J REST API endpoint via jersey client (version 2.11 from org.glassfish.jersey.core).
this is what I do:
logger.trace("sending cypher {} to endpoint {}", cypherString, nodePointUrl);
WebResource resource2 = Client.create().resource( nodePointUrl );
ClientResponse response2 = resource2
.accept( "application/json" )
.type( "application/json" )
.entity( cypherString )
.post( ClientResponse.class );
logger.debug("POST to {} returned status code {}, returned data: {}",
nodePointUrl, response2.getStatus(),
response2.getEntity(String.class));
HttpStatusCodes httpStatusCodes = HttpStatusCodes.getHttpStatusCode(response2.getStatus());
The json in the cypherstring I send to the rest api looks like this:
{"CREATE": [{"POST": {"id":"532552232906940416","text":"Warburg Research...","subject":"Warburg Research ...","teaser":"Warburg Research...","lang":"de"}}]}
The error message I receive on this is:
java.lang.String cannot be cast to java.util.Map
As you can see, my code is rather simple. I have taken it straight from neo4j website (http://neo4j.com/docs/stable/server-java-rest-client-example.html) - but it always bails out (see log below).
Please see the error log and give me a hint on what I did wrong.
Thanks in advance,
Christian
"message" : "java.lang.String cannot be cast to java.util.Map",
"exception" : "BadInputException",
"fullname" : "org.neo4j.server.rest.repr.BadInputException",
"stacktrace" : [ "org.neo4j.server.rest.repr.formats.JsonFormat.readMap(JsonFormat.java:92)", "org.neo4j.server.rest.web.RestfulGraphDatabase.createNode(RestfulGraphDatabase.java:238)", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)", "java.lang.Thread.run(Thread.java:745)" ],
"cause" : {
"message" : "java.lang.String cannot be cast to java.util.Map",
"exception" : "ClassCastException",
"stacktrace" : [ "org.neo4j.server.rest.domain.JsonHelper.jsonToMap(JsonHelper.java:53)", "org.neo4j.server.rest.repr.formats.JsonFormat.readMap(JsonFormat.java:88)", "org.neo4j.server.rest.web.RestfulGraphDatabase.createNode(RestfulGraphDatabase.java:238)", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)", "java.lang.Thread.run(Thread.java:745)" ],
"fullname" : "java.lang.ClassCastException"
}
}
{"statements": [ {"statement": "CREATE" (p:"POST" {"id":"532769886335168512","text":"my text","lang":"de"}) }]}and I'm sending it to endpoint localhost:7474/db/data/transaction. the json-string for the attributes is created with the toJsonString() method, and I add the statements-part together with corresponding parentheses before sending it over the wire.Neo.ClientError.Request.InvalidFormat","message":"Unable to deserialize request: Unexpected character ('(' (code 40)): was expecting comma to separate OBJECT entries