I need to make a POST request with params and attaching a JSON content.
Up to now:
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost("http://localhost:8983/solr/arxius/update");
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("commitWithin", "1000"));
params.add(new BasicNameValuePair("overwrite", "true"));
params.add(new BasicNameValuePair("wt", "json"));
String json = "...";
// here I need to attach json as body...
try {
httpPost.setEntity(new UrlEncodedFormEntity(params));
CloseableHttpResponse response = client.execute(httpPost);
client.close();
} catch (IOException e) {
e.printStackTrace();
}
Here curl like request:
curl 'http://localhost:8983/solr/arxius/update?_=1605619902909&commitWithin=1000&overwrite=true&wt=json'
-H 'Content-type: application/json'
--data-raw $'[{ "id": ... }]'