0

I am developing an application and want to send the content with the HttpPut request. I am sending it but it is not recognized to the remote server. I am sending the request to the REST API.

Here Is my Code:

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);
}
Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
  • What does server respond or does he not respond at all? – Alexander Kulyakhtin Aug 21 '12 at 06:27
  • Thank you for the response. No server responds but wrongly, In response i want active=false but I'm getting active=true. which means server is not responding to my request correctly. From Poster plugin I can send and get the correct response form the server, but from above code is not working . :( – user1407894 Aug 21 '12 at 06:47
  • Did you try this way http://stackoverflow.com/questions/2938502/sending-post-data-in-android – Alexander Kulyakhtin Aug 21 '12 at 07:07

0 Answers0