Hi All! What permissions I need to fetch and display issue types icons?

Iryna Balandiukh November 4, 2024

I`ve created new service project on my site, then I`ve created two issues - Task and [System] Service request. In my app I try to display issue types icons and for Service request I can not get icon due to permissions problems.

Here is my code:

const response = await api.asApp().requestJira(route`/rest/api/3/issuetype`, {

      headers: {
        Accept: "application/json"
      }
    });

 

const issueTypes = await response.json();
    let issueTypeImages = {};

    let issueTypesUrl = issueTypes.map((issueType) => ({
      name: issueType.name,
      url: issueType.iconUrl
    }));
    await Promise.all(
      issueTypesUrl.map(async (issueType) => {
        const response = await fetch(issueType.url);
        const data = await response.arrayBuffer();
        const base64String = Buffer.from(data).toString("base64");
        issueTypeImages[issueType.name] = base64String;
      })
    );


For Task everything is ok, but for 
Service request I`m getting 403 response status. 

Here is my manifest:

 

permissions:
  scopes:
    - manage:jira-configuration
    - manage:jira-project
    - read:jira-work
    - read:jira-user
    - write:jira-work
    - storage:app
    - read:application-role:jira
    - read:group:jira
    - read:user:jira
    - read:connect-jira
    - write:connect-jira
    - read:sprint:jira-software
    - read:board-scope:jira-software
    - read:board-scope.admin:jira-software
    - read:project-version:jira
    - read:issue-details:jira
    - write:user.property:jira
    - read:jql:jira
    - read:workflow:jira
    - read:project:jira
    - read:project-role:jira
    - read:filter:jira
    - read:application-role:jira
    - read:issue-type-hierarchy:jira
  content:
    styles:
      - unsafe-inline
    scripts:
      - unsafe-inline
  external:
    images:
      - "*.gravatar.com"
      - "*.wp.com"
      - "*.atl-paas.net"
      - "*.atlassian.com"
      - "*.atlassian.net"
    fetch:
      backend:
        - "*.atlassian.net"
        - "*.atlassian.com"
        - "*.tempo.io"
      client:
        - "*.atlassian.net"
        - "*.atlassian.com"
        - "*.tempo.io"

Maybe some permissions are missing? I`ll be grateful for your help

2 answers

0 votes
Iryna Balandiukh November 5, 2024

@Salih Tuç Thank you for response! I`ve tried to add read:issue-type:jiraread:avatar:jiraread:project-category:jira permissions, but this didn`t help. 

And here is full response for icons that are not displaying:

{
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: Gunzip {
_writeState: [Uint32Array],
_events: [Object],
_readableState: [ReadableState],
_writableState: [WritableState],
allowHalfOpen: true,
_maxListeners: undefined,
_eventsCount: 5,
bytesWritten: 0,
_handle: [Zlib],
_outBuffer: <Buffer 7b 22 65 72 72 6f 72 4d 65 73 73 61 67 65 73 22 3a 5b 22 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 70 65 72 6d 69 73 73 69 6f 6e 20 74 6f 20 76 ... 16334 more bytes>,
_outOffset: 0,
_chunkSize: 16384,
_defaultFlushFlag: 2,
_finishFlushFlag: 2,
_defaultFullFlushFlag: 3,
_info: undefined,
_maxOutputLength: 4294967296,
_level: -1,
_strategy: 0,
[Symbol(shapeMode)]: true,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null,
[Symbol(kError)]: null
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'https://api.atlassian.com/ex/jira/6d1d11a0-3926-4f1d-ba96-b0bf0a4a1c4d/rest/api/2/universal_avatar/view/type/issuetype/avatar/10564?size=medium',
status: 403,
statusText: 'Forbidden',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}

0 votes
Salih Tuç
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 4, 2024

Hi @Iryna Balandiukh , welcome to the Community!

I think your code is correct to get the data. If you are getting 403, it is probably getting while accessing the iconUrl for Service request.

Since this is a "System" issue type, maybe you need some granular access (that you can see from API documentation), i.e read:avatar:jira in your manifest. Can you try it by adding this to your scopes?

And also, for both requests, can you also log/print the error message in the response? If it is returning 403, the REST API is probably returning a response that contains an errorMessage, which states a useful information about the problem.

Iryna Balandiukh November 5, 2024

Thank you for response! I`ve tried to add next permissions: 

    - read:issue-type:jira
    - read:avatar:jira
    - read:project-category:jira

Also, I`ve added try\catch to get an error, but I get just response with 403 status, but no errors

try {
          response = await fetch(issueType.url);
          console.log("RESPONSEE", response);
        } catch (error) {
          console.error(`Error while fetching issue type image ${handleError(error)}`);
        }

And it is response that I receive:

{
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: Gunzip {
_writeState: [Uint32Array],
_events: [Object],
_readableState: [ReadableState],
_writableState: [WritableState],
allowHalfOpen: true,
_maxListeners: undefined,
_eventsCount: 5,
bytesWritten: 0,
_handle: [Zlib],
_outBuffer: <Buffer 7b 22 65 72 72 6f 72 4d 65 73 73 61 67 65 73 22 3a 5b 22 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 70 65 72 6d 69 73 73 69
6f 6e 20 74 6f 20 76 ... 16334 more bytes>,
_outOffset: 0,
_chunkSize: 16384,
_defaultFlushFlag: 2,
_finishFlushFlag: 2,
_defaultFullFlushFlag: 3,
_info: undefined,
_maxOutputLength: 4294967296,
_level: -1,
_strategy: 0,
[Symbol(shapeMode)]: true,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null,
[Symbol(kError)]: null
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'https://api.atlassian.com/ex/jira/6d1d11a0-3926-4f1d-ba96-b0bf0a4a1c4d/rest/api/2/universal_avatar/view/type/issuetype/avatar/10568?size=medium', status: 403,
statusText: 'Forbidden',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}
Iryna Balandiukh November 5, 2024

Thank you for response! I`ve tried to add read:issue-type:jiraread:avatar:jiraread:project-category:jira permissions, but this didn`t help. 

And here is full response for icons that are not displaying:

{
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: Gunzip {
_writeState: [Uint32Array],
_events: [Object],
_readableState: [ReadableState],
_writableState: [WritableState],
allowHalfOpen: true,
_maxListeners: undefined,
_eventsCount: 5,
bytesWritten: 0,
_handle: [Zlib],
_outBuffer: <Buffer 7b 22 65 72 72 6f 72 4d 65 73 73 61 67 65 73 22 3a 5b 22 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 70 65 72 6d 69 73 73 69 6f 6e 20 74 6f 20 76 ... 16334 more bytes>,
_outOffset: 0,
_chunkSize: 16384,
_defaultFlushFlag: 2,
_finishFlushFlag: 2,
_defaultFullFlushFlag: 3,
_info: undefined,
_maxOutputLength: 4294967296,
_level: -1,
_strategy: 0,
[Symbol(shapeMode)]: true,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null,
[Symbol(kError)]: null
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'https://api.atlassian.com/ex/jira/6d1d11a0-3926-4f1d-ba96-b0bf0a4a1c4d/rest/api/2/universal_avatar/view/type/issuetype/avatar/10564?size=medium',
status: 403,
statusText: 'Forbidden',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}

Iryna Balandiukh November 5, 2024

@Salih Tuç  Thank you for response! I`ve tried to add read:issue-type:jiraread:avatar:jiraread:project-category:jira permissions, but this didn`t help. 

And here is full response for icons that are not displaying:

{
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: Gunzip {
_writeState: [Uint32Array],
_events: [Object],
_readableState: [ReadableState],
_writableState: [WritableState],
allowHalfOpen: true,
_maxListeners: undefined,
_eventsCount: 5,
bytesWritten: 0,
_handle: [Zlib],
_outBuffer: <Buffer 7b 22 65 72 72 6f 72 4d 65 73 73 61 67 65 73 22 3a 5b 22 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 70 65 72 6d 69 73 73 69 6f 6e 20 74 6f 20 76 ... 16334 more bytes>,
_outOffset: 0,
_chunkSize: 16384,
_defaultFlushFlag: 2,
_finishFlushFlag: 2,
_defaultFullFlushFlag: 3,
_info: undefined,
_maxOutputLength: 4294967296,
_level: -1,
_strategy: 0,
[Symbol(shapeMode)]: true,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null,
[Symbol(kError)]: null
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'https://api.atlassian.com/ex/jira/6d1d11a0-3926-4f1d-ba96-b0bf0a4a1c4d/rest/api/2/universal_avatar/view/type/issuetype/avatar/10564?size=medium',
status: 403,
statusText: 'Forbidden',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}

Salih Tuç
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 5, 2024

Hmm, the value of iconUrl seems different. As I saw from the URL, the avatar id is 10564. Can you please try to request following link:

https://<your-domain.atlassian.net>/secure/viewavatar?size=xsmall&avatarId=10564&avatarType=issuetype

Is it returning something meaningful?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events