if (POLICY.BASIC_AUTH == authPolicy) {
try {
httpClient.setBasicAuthenticateToRequest();
} catch (SocialClientLibException e) {
throw new SocialHttpClientException(e.getMessage(), e);
}
}
HttpPost httpPost = new HttpPost(targetURL);
Header header = new BasicHeader("Content-Type", "application/json");
httpPost.setHeader(header);
//Post method with the HttpParams
if (params != null) {
httpPost.setParams(params);
}
try {
//Provides when uses post so does not have any data.
byte[] postData = convertModelToByteArray(model);
if (postData != null) {
ByteArrayEntity entity = new ByteArrayEntity(convertModelToByteArray(model));
httpPost.setEntity(entity);
}
HttpResponse response = httpClient.execute(targetHost, httpPost);
//handleError(response);
//Debugging in the devlopment mode
if (SocialClientContext.isDeveloping()) {
dumpHttpResponsetHeader(response);
dumpContent(response);
}
return response;
} catch (ClientProtocolException cpex) {
throw new SocialHttpClientException(cpex.toString(), cpex);
} catch (IOException ioex) {
throw new SocialHttpClientException(ioex.toString(), ioex);
}
}