I had a problem getting all users through API in my Connect app. I could use the same method to get the response from the apis like /issue/{issueKey}
, but it does not work for /users/search
.
Informations
API: /rest/api/3/users/search
Code snap:
public void getAllUsers(@AuthenticationPrincipal AtlassianHostUser hostUser) {
String preEncodedUriString = apiPrefix + "/users/search";
UriComponents uriComponents = UriComponentsBuilder.fromUriString(preEncodedUriString).build(true);
JsonNode jsonNode = atlassianHostRestClients.authenticatedAsAddon().getForObject(uriComponents.toUri(), JsonNode.class);
}
descriptor(scpoe):
******
******
"authentication": {
"type": "jwt"
},
"lifecycle": {
"installed": "/installed",
"uninstalled": "/uninstalled"
},
"scopes": [
"READ",
"WRITE",
"DELETE",
"ADMIN",
"ACT_AS_USER"
],
******
******
Error Messages:
In debug mode:
- atlassianHostRestClients.authenticatedAs(hostUser).getForObject(uriComponents.toUri(),Void.class)
- atlassianHostRestClients.authenticatedAsHostActor().getForObject(uriComponents.toUri(),Void.class)
- atlassianHostRestClients.authenticatedAsAddon().getForObject(uriComponents.toUri(),Void.class)
They all throw the same error:
Method threw 'org.springframework.web.client.HttpClientErrorException$Forbidden' exception.
What I tried
- I tried to set the
Global Permission
to my current user. - Reinstall the connect app