This isn't really an Android specific problem.
However, your content type is wrong if you are sending the JSON as a POST
parameter. You should be using form encoding or even multipart.
If you a dumping the JSON into the POST data then you should likely be
using a PUT instead of a POST.
On Wednesday, 13 February 2013 10:09:46 UTC-5, Bajrang Asthana wrote:
>
> I am trying to send JSON object from android app to my servlet using
> HttpPost.
> But while retrieving this JSON object at server side I am getting null.
> Below is code snippet-
>
> In android app-
>
> HttpClient client = new DefaultHttpClient();
>>
>> HttpPost request = new HttpPost(hostNameCollection);
>>
>> StringEntity se = new StringEntity(jsonObj.toString());
>>
>> request.setHeader("Accept", "application/json");
>> request.setHeader("Content-type", "application/json");
>>
>>
>> request.setEntity(se);
>> HttpResponse response = client.execute(request);
>>
>>
> In java servlet(under post method)-
> req.getParameterMap();
>
> I have also try to send post parameter using NameValuePair but it could
> also not solve the problem.
>
> Please suggest what should I do to get rid of this.
>
> Thanks in advance. :)
>
>
>
>
>
>
>
>
--
--
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
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.