Hello all.
I'm trying to call one of REST services from groovy script. I'm doing it this way:
HttpClient client=new DefaultHttpClient(); HttpEntity requestEntity=null; try{ requestEntity=new StringEntity(json); HttpPost post = null; post = new HttpPost("https://myjira.com:8443/rest/tempo-teams/1/team"); post.setHeader("Authorization", "Basic base64_encoded_login"); post.addHeader("Content-Type", "application/json;charset=utf-8"); post.setEntity(requestEntity); ResponseHandler<String> handler = new BasicResponseHandler(); HttpResponse response = client.execute(post); String body = handler.handleResponse(response); int statusCode = response.getStatusLine().getStatusCode(); if(statusCode!=HttpStatus.SC_OK){ System.err.println("Status code = " + statusCode); System.err.println("Method failed: "+method.getStatusLine()); } System.out.println("BODY = \n"+body); System.out.println("CODE = " + statusCode ); }
service works successfully but russian symbols are displayed as "?", and that's the trouble.
They're in json string.
As you see i set encoding in Content-Type header.
May be i need to change system's groovy encoding?
Thanks in advance.
Community moderators have prevented the ability to post new answers.
requestEntity=
new
StringEntity(json,HTTP.UTF_8) is the answer.
hey guys help me to integrate JIRA to Salesforce...i am sfdc developer but business asks me write JIRA code to push issues from jira side to salesforce which need to be done via JIRA code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also all the application encoding settings are set to UTF-8 and everything is fie if calling rest service via rest client.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.