Hello,
I send a regular request to get project role api, however it always returns 401 Unauthorized. My manifest.yml file includes read:jira-work and manage:jira-configuration scopes. I also checked a related post in community, but in my case I can see this role in a company project as well and assign it to users. What could be the problem? This is how I sent the requests:
const rolesResponse = await API.asApp().requestJira(route`/rest/api/3/project/${projectKey}/role/`);
console.error("Roles response: ", rolesResponse);
if (!rolesResponse.ok) throw new Error("Unable to fetch user roles.");
const links = (await rolesResponse.json());
const rolesOfUser = [];
for (const role of roles) {
if (links[role]) {
const link = links[role].substring(links[role].indexOf("/rest"), links[role].length);
const response = await API.asUser().requestJira(route`${link}`, {
headers: {
accept: "application/json",
"content-type": "application/json",
}
});
console.error("Insider response: ", link, response);
const isOk = response.status === 200;
if (isOk) {
const data = await response.json();
if (data.actors !== undefined) {
const roleActors = data.actors.map(
(actor) => actor.actorUser.accountId,
);
if (
roleActors.some((actorAccountId) => actorAccountId === accountId)
) {
rolesOfUser.push(data.name);
}
}
} else throw new Error();
}
}
Kind regards,
Odin