0
public static void putRequestToPrestashop(String id,String newXML) throws IOException{

    final String login = "VNIPG9YYCESFNK0CLXQNIDBJR24WQZ5E";
    final String password ="";


    //DefaultHttpClient has been depricated, use HttpClientBuilder instead.
    HttpClient httpClient = HttpClientBuilder.create().build();

    httpClient.getCredentialsProvider().setCredentials(
                    new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, "basic"),
                    new UsernamePasswordCredentials(login, password));


    HttpPut putRequest = new HttpPut("http://127.0.0.1:4001/prestashop/api/products/"+id);
    //System.out.println("putREQ:  "+putRequest);

    StringEntity input = new StringEntity(newXML);
    input.setContentType("text/xml");

    putRequest.setEntity(input);
    HttpResponse response = httpClient.execute(putRequest);

    System.out.println(response);
    httpClient.getConnectionManager().shutdown();

}

私が得るエラーは次のとおりです。

HTTP/1.1 400 Bad Request [Date: Fri, 05 Jul 2013 08:49:39 GMT, Server: Apache/2.2.15 (Win32) PHP/5.3.2, Vary: Host, X-Powered-By: PrestaShop Webservice, Access-Time: 1373014179, PSWS-Version: 1.5.4.1, Execution-Time: 0.072, Content-Length: 241, Connection: close, Content-Type: text/xml;charset=utf-8]

ユーザー名とパスワードは間違いなく正しく、問題なくローカルで API にアクセスできます。また、API に GET リクエストを送信し、問題なく応答を取得できます。

不正なリクエストの原因と思われるものを誰でも見つけることができますか???

編集: newXML ファイルは次の場所で確認できます。http://pastebin.com/RbBPwCbH

newXML の形式は正しく、prestashop から取得した get 応答形式と正確に一致しています。

4

0 に答える 0