2014-02-19 160 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);' –

相關問題