Forge App Get User AccountID for customer

Hey,

I am currently building an APP for JIRA Service Management using Assets via REST API. The App is fetching Assets from JIRA Cloud as App with Credentials provided. To filter for user specific assets I am trying to get the AccountID of the current User - without success.
I’ve added the scopes:
scopes: [read:cmdb-object:jira, read:jira-user]

and tried to call rest in resolver:
const userResponse = await api.asUser().requestJira(
route/rest/api/3/myself,
{
headers: {
Accept: ‘application/json’,
},
}
);

and get context in frontend and pass it through
useEffect(() => {
const fetchData = async () => {
const context = await getContext(); // z. B. issueId, accountId etc.
const result = await invoke(‘getAssets’, {
context
});
console.log(result);
// … dein Code
};

fetchData();
}, );

both is not working. Am I missing a crucial point? The app is providing jiraServiceManagement:portalUserMenuAction so its part of the Service Desk and I am logged in as a customer user using:
unlicensedAccess:
- customer

Can someone help?

Thanks,
Fabian

Hi @FabianWallentowitz

Does the API you are using return the right information if you try and load it directly in the browser while logged in as a customer account? I wonder if the issue is because the “myself” API is designed for returning Jira users, but JSM customer accounts are not necessarily a full Jira user.

Heey,
yes I am logged in to the JSM Service Desk with a customer account. It returns undefined. What is the correct way to fetch customer account ID in JSM (Service Desk) App? Via Bridge? Rest? Tried a lot now without any success…:frowning:

It looks like this might be a gap in the JSM REST API: https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-customer/#api-group-customer - it only has an endpoint for creating a new customer account.

Let me check in with the JSM team if they have any suggestions and get back to you.

Hey,
I solved it now with using the context of the resolver function called.

resolver.define(‘getAssets’, async ({ payload, context }) => {
const accountId = context.accountId;
}

This ID can be used in AQL and works. :slight_smile:

1 Like