user_mda user_mda - 1 year ago 80
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

Answer Source

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

Placing the Boolean true instead of the String true.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download