I trying to send two parameters to some server.
the server is responding to http-post call and the two parameters are
Int
Some Enum ( that i sending as string )
I want to send the parameters as json:
StringEntity t = new StringEntity("{ \"intValParam\":-100 , \"enumParam\":\"enumValueAsString\" }" , "UTF-8");
httppost.setEntity(t);
httppost.setHeader("content-type", "application/json");
The response that i get is 400 ( bad request )
** There is one more method that i can call that need to have one parameter … only the int – and this method is working good – so this is not problem from the bad connection or something like that.
You should not try to add your parameters like that. Either use the method
setParamsfrom httpPost or use NameValuePair entities and encode them in your request, like that :code taken here.