I need to make POST request to REST web-service with header params and form params. I have description of web-service method:
Method: POST /
Produces: application/json /
Consume: application/x-www-form-urlencoded / and etc.
and list of header and form params that I need to send.
Can anybody clarify what is Produces and Consume and how to form a request?
As I undestand:
httpPost = new HttpPost(webServiceUrl + methodName);
httpPost.setHeader("headerParamName", headerParam);
entity = jsonObject.put(param.getKey(), param.getValue());//param - form param
httpPost.setEntity(entity);
httpPost.setHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF8"); //???
Sorry in advance if question is dummy.
Produces should be the type of data that the web service will return (i.e., it is the type of data that your method will receive), whilst Consume should be the type of data that the web service expects to receive (i.e., the data you are passing from your method).
So I think you have to set: