I have added a portalHeader to a JSM project and have added an invoke call back to a resolver.
In the resolver, I call the following to try and get a list of the Organizations for the customer.
// Get the list of organizations associated with a customer
const fetchOrganizationsForUser = async (serviceDeskId, accountId) => {
console.log(`fetchOrganizationsForUser(serviceDeskId=${serviceDeskId}, accountId=${accountId})`);
// Get the organizations in the instance
try {
// Fetch organization details using the Jira Service Management API
const searchParams = new URLSearchParams({ accountId: accountId });
const url = `/rest/servicedeskapi/servicedesk/${serviceDeskId}/organization?${searchParams}`;
console.log(url);
const response = await api.asApp().requestJira(route(url));
if (!response.ok) {
throw new Error(`Failed to fetch organizations for user. Details: ${response.status}`);
}
const data = await response.json();
return data.values;
} catch (error) {
console.error('Error fetching organization for user:', error);
return(null);
}
}
The manifest looks a bit like this:
jiraServiceManagement:portalHeader:
- key: add-customer-to-asset-portal-header
resource: header
resolver:
function: resolver
render: native
unlicensedAccess:
- unlicensed
- anonymous
- customer
... removed for clarity ...
permissions:
scopes:
- manage:servicedesk-customer
I am getting a 401 no matter if I try asApp or AsUser.
How do I resolve this?