neo4j/community — Issue #251: Batch REST API returns error 500 in Windows
Author: simosug
Created: 2012-02-17 09:17:07+00:00
State: open

In Windows machines, a batch job cannot successfully execute from the REST API if launched in CURL or by a custom .NET REST API client implementation.
The problem does not occur when using the neo4j HTTP power console

------ with CURL
curl -vX POST http://localhost:7474/db/data/batch -d
'[{"method":"POST","to":"/node","body":{"name":"Foo Bar"}}]' -H
"Content-Type: application/json" -H "Accept: application/json"
* About to connect() to localhost port 7474 (#0)
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 7474 (#0)
> POST /db/data/batch HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-pc-win32) libcurl/7.24.0
> Host: localhost:7474
> Content-Type: application/json
> Accept: application/json
> Content-Length: 46

* upload completely sent off: 46 out of 46 bytes
< HTTP/1.1 500 Internal Server Error
< Content-Length: 4262
< Content-Encoding: UTF-8
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< Server: Jetty(6.1.25)
<
{
"message" : "Unexpected character (''' (code 39)): expected a valid
value (number, String, array, object, 'true', 'false' o
r 'null')\n at [Source: org.mortbay.jetty.HttpParser$Input@685de82a;
line: 1, column: 2]",
"exception" : "org.codehaus.jackson.JsonParseException: Unexpected
character (''' (code 39)): expected a valid value (numbe
r, String, array, object, 'true', 'false' or 'null')\n at [Source:
org.mortbay.jetty.HttpParser$Input@685de82a; line: 1, colu
mn: 2]",
"stacktrace" :
[ "org.codehaus.jackson.JsonParser._constructError(JsonParser.java:
1291)", "org.codehaus.jackson.impl.JsonPa
rserMinimalBase._reportError(JsonParserMinimalBase.java:385)",
"org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpe
ctedChar(JsonParserMinimalBase.java:306)",
"org.codehaus.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf8StreamParse
r.java:1581)",
"org.codehaus.jackson.impl.Utf8StreamParser._nextTokenNotInObject(Utf8StreamParser.java:
436)", "org.codehaus.j
ackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:322)",
"org.neo4j.server.rest.web.BatchOperationService.performB
atchOperations(BatchOperationService.java:97)",
"sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",
"sun.reflect.N
ativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)",
"sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegatin
gMethodAccessorImpl.java:25)",
"java.lang.reflect.Method.invoke(Method.java:597)",
"com.sun.jersey.spi.container.JavaMethodIn
vokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)",
"com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceM
ethodDispatchProvider
$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:
205)", "com.sun.jersey.server.
impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:
75)", "com.sun.jersey.serv
er.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)",
"com.sun.jersey.server.impl.uri.rules.ResourceClassRule.ac
cept(ResourceClassRule.java:108)",
"com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:
147)
",
"com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:
84)", "com.sun.jersey.se
rver.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:
1469)", "com.sun.jersey.server.impl.applicati
on.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)",
"com.sun.jersey.server.impl.application.WebApplicationIm
pl.handleRequest(WebApplicationImpl.java:1349)",
"com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(Web
ApplicationImpl.java:1339)",
"com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:
416)", "com.sun.jer
sey.spi.container.servlet.ServletContainer.service(ServletContainer.java:
537)", "com.sun.jersey.spi.container.servlet.Servlet
Container.service(ServletContainer.java:699)",
"javax.servlet.http.HttpServlet.service(HttpServlet.java:820)",
"org.mortbay.j
etty.servlet.ServletHolder.handle(ServletHolder.java:511)",
"org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Se
rvletHandler.java:1166)",
"org.neo4j.server.statistic.StatisticFilter.doFilter(StatisticFilter.java:
62)", "org.mortbay.jetty.
servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:
1157)", "org.mortbay.jetty.servlet.ServletHandler.handle(Serv
letHandler.java:388)",
"org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
182)", "org.mortbay.jetty.handler
.ContextHandler.handle(ContextHandler.java:765)",
"org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:
114)",
"org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)", "org.mortbay.jetty.Server.handle(Server.ja
va:326)",
"org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
542)", "org.mortbay.jetty.HttpConnection$Reques
tHandler.content(HttpConnection.java:943)",
"org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)",
"org.mortbay.jetty
.HttpParser.parseAvailable(HttpParser.java:218)",
"org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)",
"org.mo
rtbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
410)", "org.mortbay.thread.QueuedThreadPool$PoolThread.run(
QueuedThreadPool.java:582)" ]
}* Connection #0 to host localhost left intact

* Closing connection #0
------

------ with HTTP console
http> POST /db/data/batch [{"method":"POST", "to":"\/node", "body":
{"Foo":"Bar"}, "id":1}]
==> 200 OK
==> [{"id":1,"location":"http://localhost:7474/db/data/node/12","body":
{
==> "outgoing_relationships" : "http://localhost:7474/db/data/node/
12/relationships/out",
==> "data" : {
==> "Foo" : "Bar"
==> },
==> "traverse" : "http://localhost:7474/db/data/node/12/traverse/
{returnType}",
==> "all_typed_relationships" : "http://localhost:7474/db/data/node/
12/relationships/all/{-list|&|types}",
==> "property" : "http://localhost:7474/db/data/node/12/properties/
{key}",
==> "self" : "http://localhost:7474/db/data/node/12",
==> "properties" : "http://localhost:7474/db/data/node/12/
properties",
==> "outgoing_typed_relationships" : "http://localhost:7474/db/data/
node/12/relationships/out/{-list|&|types}",
==> "incoming_relationships" : "http://localhost:7474/db/data/node/
12/relationships/in",
==> "extensions" : {
==> },
==> "create_relationship" : "http://localhost:7474/db/data/node/12/
relationships",
==> "paged_traverse" : "http://localhost:7474/db/data/node/12/paged/
traverse/{returnType}{?pageSize,leaseTime}",
==> "all_relationships" : "http://localhost:7474/db/data/node/12/
relationships/all",
==> "incoming_typed_relationships" : "http://localhost:7474/db/data/
node/12/relationships/in/{-list|&|types}"
==> },"from":"/node"}]
------

The issue has been discussed in google groups too:
http://groups.google.com/group/neo4j/browse_thread/thread/8d439eb541f8b019/4b4ad86a3b69d8e7