Unable to use requestJira for JSM cloud API endpoint

As per the title, im attempting to use requestJira with a JSM cloud API endpoint within my forge Jira app, however it returns a fetch error regarding the auth token:

”Failed to fetch context Error: An unexpected error occurred when fetching an auth token”

The specific endpoint im trying to use is:
GET /rest/servicedeskapi/organization
As per the docs I’ve implemented the needed scopes for the endpoint, and the authentication section of JSM cloud API states that you can use Forge for invocations. However, the endpoint does not have an example for Forge (requestJira) and access seems to be via bearer tokens

Anyone have any luck with using requestJira with the JSM cloud endpoints?

From my experience, this error can happen for multiple reason, but the most probable in your case, is that your user on JSM is not a real Atlassian user, aka just a customer, and this is not supported by Atlassian/Forge/JSM.

To work around this, you have to invoke either a resolver or a remote, that does the Jira request and returns the response to the frontend. This is obviously slower, and now you paid the compute for each request :frowning:

Thanks for your reply Silvre.

That might be the case. The issue i believe is due to the fact that this particular API endpoint requires a bearer token. Most other requestJira calls done via app code comes out okay due to app serving as the user via app context.

Would you mean that calling the endpoint request via the resolver would work without the need for a bearer token? Otherwise the only alternative I have now is using a curl request with an API key, which can be troublesome as the key would need to be updated regularly after expiry

Edit: Solution: endpoint works fine on the resolver end routing asApp. So it was as you suggested Silvre.

I think the endpoint documentation may be out of date as i believe api.asApp.requestJira uses OAuth 2.0 like everything on the Jira REST api

From the documentation of this endpoint, it should work out of the box from Forge with requestJira.

Do you have the right permission in the manifest (either anage:servicedesk-customer or read:organization:jira-service-management) and re-deploy and re-install your app ?

Hi Silvre. Yes I have declared the right scopes and redeployed + installed. However when its called on the client side, it returns with a failure regarding auth token being incorrect.

However im using requestJira as the standalone function without ‘route’. Perhaps it is accessing the api as user. Could try route as app on the client side see if it goes through.

Nonetheless other Jira Cloud APIs using Oath 2.0 go through fine with just requestJira alone on the client side without needing to declare api.asApp. Since this endpoint states authentication as Oauth 2.0 it should technically work.