I'm using Apache HttpClient 4.2 and just need to fetch the title property from the JSON response below.
Would I need to use the EntityUtils.toString() method for this?
Code
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost(MAILCHIMP_API_URL);
postRequest.setHeader("Content-Type", "application/json");
postRequest.setHeader("Authorization", "Basic " + MAILCHIMP_API_KEY_BASE64);
StringEntity entity = new StringEntity(json.toString(), "UTF8");
postRequest.setEntity(entity);
HttpResponse response = httpClient.execute(postRequest);
// Closes the connection
EntityUtils.consume(response.getEntity());
JSON Response
{
"type": "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
"title": "Member Exists",
"status": 400,
"detail": "[email protected] is already a list member. Use PUT to insert or update list members.",
"instance": ""
}