user_mda user_mda - 9 months ago 25
JSON Question

Getting a 400 after setting json parameters

I am trying to send the following json to a REST server from JAVA



I am setting it as follows in my HttpClient

JSONObject json = new JSONObject();
json.put("ignore_volumes", "true");
StringEntity params = new StringEntity(json.toString());
HttpResponse response = client.execute(post);

This gives me a 400, after I remove

json.put("ignore_volumes", "true");

this is a valid input , not sure whats going on. The json from curl works fine, only fails in java


Have you tried json.put("ignore_volumes", true);?

Placing the Boolean true instead of the String true.