Get 403 forbidden when making request to the Jira cloud rest api

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

Hi @RogerFan ,

I went through the docs for your user search API Get All users. Below the permissions, you can find that Connect Apps cannot use this REST resource.
Hope, this clarifies your query.

Cheers!!

1 Like

Hi @ShubhamTyagi

Thank you so much for providing the information! I carefully went through the documentation for the user search API to get all users, and I found the relevant details, confirming that Connect Apps cannot use this REST resource. I truly appreciate your assistance as it has resolved my query.

Thank you for your patience and support!

Best regards

1 Like