I am having a dilemma here: this is confusing to me.
Code
StringEntity stringEntityInstance = new StringEntity("some string", "UTF-8");
HttpPost req = new HttpPost("myurl");
req.setEntity(stringEntityInstance);
- If add
code A
then I face some JSON error from API - If add
code B
then I don't face any issue.
Code A
stringEntityInstance.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,”application/json"));
Code B
req.setHeader(HTTP.CONTENT_TYPE,”application/json");
Any help is appreciated !