Is there any alternative to pass URL parameters using PostMethod? After this an XML needs to be posted along with the URL. Since it is a post request, the URL parameters should be passed in the Request body and should not be visible. Can addParameter method be used?
URL- http://mytest.com?abc=xyz&token=aisk%2s
1)
//this works ( no utf-8 encoding)
PostMethod pm =new PostMethod("http://mytest.com");
pm.setQueryString("abc=xyz");
pm.setQueryString("token=aisk%2s");
2)
// it encodes utf-8 and fails
PostMethod pm =new PostMethod("http://mytest.com");
NameValuePair [] nvp= new NameValuePair[2];
nvp[0]=new NameValuePair("abc","xyz");
nvp[1]=new NameValuePair("token","aisk%2s");
//encodes the token value as aisk%252s
pm.setQueryString(nvp);
An XML needs to be posted after setting the above URL parameters.
pm.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF-8"));