我尝试了一个简单的密码休息请求。但我收到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);
}
}
答案 0 :(得分:1)
确保application/json
用于Accept
和Content-Type
HTTP标头。如果这没有帮助,请转储完整的请求和完整的回复,并将其附加到您的问题。