My question might seem like possible duplicate of posts mentioned in stackoverflow, but none of those are able to resolve my issue. I am trying to pass some parameters with my URL using HTTP POST method. Following is my code :
HttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost("http://urlname/_search");
List<NameValuePair> nameValue = new ArrayList<NameValuePair>();
nameValue.add(new BasicNameValuePair("size", "1"));
httpPost.setEntity(new UrlEncodedFormEntity(nameValue));
HttpResponse httpResponse = httpClient.execute(httpPost);
I get 400 response status when running the code. I want to basically run http://urlname/_search?size=1 which runs well on browser directly as URI. I think I am doing some basic syntax error. Also, using the POST request (http://urlname/_search) without parameters is working well and yielding the expected results. Any help is appreciated :)