0

アプリケーションを開発していて、HttpPut リクエストでコンテンツを送信したいと考えています。送信していますが、リモートサーバーに認識されません。リクエストを REST API に送信しています。

これが私のコードです:

HttpURLConnection connection;
try{
    URL url = new URL(Constants.url_domain+"listings/"+idvalue);
    //URL url = new URL(imageUrl);
    HttpPut httpRequest = null;
    httpRequest = new HttpPut(url.toURI());                     
    String basicAuth = "Basic " + new String(Base64.encode("username:password123#".getBytes(),Base64.NO_WRAP ));
    httpRequest.setHeader("Authorization", basicAuth);                      
    MultipartEntity entity2 = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    entity2.addPart("title",new StringBody(titlevalue));
    entity2.addPart("price",new StringBody(pricevalue));
    entity2.addPart("active",new StringBody("false"));                                          
    httpRequest.setEntity(entity2);                    
    HttpClient httpclient = new DefaultHttpClient();
    HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
}
4

0 に答える 0