2014-02-19 159 views
1

我尝试了一个简单的密码休息请求。但是,我收到了400个错误的请求作为回应。请求输出似乎没问题。怎么了?Cypher请求通过Rest返回400错误请求,为什么?

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

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

+0

我以为我试过之前没有成功,但现在它的工作。谢谢。 ClientResponse cypherResponse = cypher.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class,request);' –

相关问题