Can't send plus('+') symbol as %2B to JIRA using Spring RestTemplate

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Can't send plus('+') symbol as %2B to JIRA using Spring RestTemplate



Works well without encoding (when there is no special character) but when I do encoding for special characters I get exception. I am using UTF-8 encoding.


RestTemplate restTemplate = new RestTemplate();

headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Authorization", jiraBasicAuthorization);
entity = new HttpEntity<>("parameters", headers);

String query = jql.replace("+", "%2B");
return
restTemplate.exchange("urlToJira?expand=changelog&jql=jql&maxResults=1000",
HttpMethod.GET, entity, SearchResponse.class, query);

//OR
String query = "";
try
query = URLEncoder.encode(searchJQL, "UTF-8");
catch (UnsupportedEncodingException e)
e.printStackTrace();

return restTemplate.exchange("urlToJira?expand=changelog&jql=jql&maxResults=1000",
HttpMethod.GET, entity, SearchResponse.class, query);









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard