hi,

i Am Getting issue on posting data to restful service using http post

I am getting Response body from service:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
  <head>
    <title>Request Error</title>
  </head>
  <body>
    <div id="content">
      <p class="heading1">Request Error</p>
      <p>The server encountered an error processing the request. See
server logs for more details.</p>
    </div>
  </body>
</html>

Response Code:400

Response Message : Bad Request



my code is:

String address="http://bb5739d189b24f6a9078b5fd03f87d88.cloudapp.net/
SjaapperService.svc/Update";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(address);
product1 =new ArrayList<NameValuePair>();
ProductStatus mb = new ProductStatus(product);
Gson gson = new Gson();
String json = gson.toJson(mb);
product1.add(new BasicNameValuePair("Jsonstring",json));
try {
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(product1);
post.setEntity(formEntity);
try {
HttpResponse response = client.execute(post);
HttpEntity resEntity = response.getEntity();
tring vv=resEntity.toString();
String responseBody = EntityUtils.toString(response.getEntity());
int responseCode = response.getStatusLine().getStatusCode();
String x=response.getStatusLine().getReasonPhrase();
Log.i("Responsecode", x);
String s=x;
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

thats url accepts json string value only

please Help me....

thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to