One of the requests on my page has some parameters and in Firefox DevTool it looks like:
How is it possible to create this structure in url or just add parameters in Java?
Usually I use Apache HttpPost
and then:
ArrayList<NameValuePair> postParameters;
postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("key", "value"));
httpPost.setEntity(new UrlEncodedFormEntity(postParameters, "UTF-8"));
but have no idea how to pass json as my request parameter...
@Update
So in my example should it looks like:
Map<String, Object> comMap = new HashMap<String, Object>();
Map<String, Object> iMap = new HashMap<String, Object>();
Map<String, Object> mainMap = new HashMap<String, Object>();
comMap.put("p","A");
iMap.put("com", comMap);
iMap.put("t", "b");
mainMap.put("ex", null);
mainMap.put("i(2)", null);
mainMap.put("i(3)", iMap);
where i(2)
is i
from second line and i(3)
is i
from third line?
How is it possible to add map to HttpPost
(if it is correct)?
@Update
I send requests by using:
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost;
httpClient = new DefaultHttpClient();
httpPost = new HttpPost("myUrl");
httpPost.setHeader("headerKey","headerValue");
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("paramKey", "false"));
httpPost.setEntity(new UrlEncodedFormEntity(postParameters, "UTF-8"));
HttpResponse response = httpClient .execute(httpPost);