I have some services with the following header and I want to call these methods in Android application. I wrote the following code for calling service is correct but if I add charset=utf-8 to the header, I get 400 error code. I should send Persian character in some methods and without UTF-8, I get incorrect characters on the server-side. Anyway, Please send your suggestion to edit my code.
Another note: I work with PostMan and post Persian character to the service and it shows correct characters.
WCF Header method:
OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest,
UriTemplate = "Test")]
Android Code:
this.jsonStringer=params[0].toString();
HttpPost request = new HttpPost(uri);
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");
StringEntity msg = new StringEntity(jsonStringer);
msg.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,
"application/json"));
msg.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
"application/json"));
request.setEntity(msg);
response = httpClient.execute(request);
When I add request.setHeader("Content-type", "application/json; charset=utf-8"); I get 400 error code!