通过Rest的Cypher请求返回400 Bad Request,为什么?

时间:2014-02-19 16:13:44

标签: java rest neo4j jersey

我尝试了一个简单的密码休息请求。但我收到400 Bad Request作为回复。请求输出似乎没问题。怎么了?

public class HelloRest {
  public static String SERVER_ROOT_URI = "http://localhost:7474/db/data/";

  public static void main(String[] args) {
    Client client = Client.create();
    client.addFilter(new LoggingFilter(System.out));
    WebResource cypher = client.resource(SERVER_ROOT_URI + "cypher");
    String request = "{\"query\":\"MATCH (n) RETURN n\"}";
    ClientResponse cypherResponse = cypher.post(ClientResponse.class, request);
    System.out.println(cypherResponse);
  }
}

1 个答案:

答案 0 :(得分:1)

确保application/json用于AcceptContent-Type HTTP标头。如果这没有帮助,请转储完整的请求和完整的回复,并将其附加到您的问题。