Can't send plus('+') symbol as %2B to search by user key like someus+erkey

I use java and atlassian-connect-spring-boot and I need to send request to 


User key is usually a part of email And emails allow using plus sign in them. The problem is that I can't use this code to send valid request.

return atlassianHostRestClients.authenticatedAsAddon().getForObject("/rest/api/2/user?key={0}", UserModel.class, "someus+erkey")

It seems that AtlassianConnectHttpRequestInterceptor decode someus%2Berkey and send it like someus+erkey. I'm getting org.springframework.web.client.HttpClientErrorException: 404 Not Found.

Is there any way to send request with encoded plus symbol with atlassian-connect-spring-boot?

1 answer

1 accepted

This widget could not be displayed.

To solve the problem, I used the following solution:

protected <T> ResponseEntity<T> sendCustomGet(String path, MultiValueMap<String, String> valueMap, Class<T> type) {
String baseUrl = getHostFromSecurityContext().map(AtlassianHost::getBaseUrl).orElse("");
MultiValueMap<String, String> encodedValueMap = new LinkedMultiValueMap<>();
valueMap.forEach((k, l) -> {
List<String> encodedValueList = new ArrayList<>();
l.forEach(v -> {
try {
encodedValueList.add(URLEncoder.encode(v, "UTF-8"));
} catch (UnsupportedEncodingException e) {
encodedValueMap.put(k, encodedValueList);

URI uri = UriComponentsBuilder.fromUriString(baseUrl).path(path)

String token = atlassianHostRestClients.createJwt(HttpMethod.GET, uri);
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "JWT " + token);
RestTemplate template = new RestTemplate();

return, HttpMethod.GET, new HttpEntity<String>(headers), type);

 1. Get baseUrl from context


 2. Manually encode query parameters.

 3. Build URI with build(true).

 4. Generate JWT token atlassianHostRestClients.createJwt(HttpMethod.GET, uri) and add it to headers.

 5. Send request with method.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

292 views 5 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you