Hello,
I’m building a Forge Application. In the past, I was able to make some requests to REST API v3. For instance, I was able to append a scope read:jira-user
to my manifest.yml
and make a request like this one:
resolver.define('getUsers', async ({ context }) => {
const {
extension: {
project: { key: projectKey },
}
} = context;
const response = await api.asApp().requestJira(
route`/rest/api/3/user/assignable/multiProjectSearch?projectKeys=${projectKey}`,
{
headers: {
'Accept': 'application/json'
},
},
);
...
});
My understanding is that the code above uses REST API 3.
Question 1 - can my Forge app access REST API 1?
Let’s say that I want to get the sprint data. I thought that all I have to do is to append new scope to permissions section: read:sprint:jira-software
(see the documentation https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-get) and then make a request:
resolver.define('getOtherData', async ({ payload }) => {
const sprintResponse = await api.asApp().requestJira(
route`/rest/agile/1.0/sprint?state=active`,
{
headers: {
'Accept': 'application/json'
},
},
);
const sprint = await sprintResponse.json();
console.log(sprint);
});
Unfortunately I what I got in my console is:
{ code: 401, message: 'Unauthorized; scope does not match' }
.
Question 2 - what am I missing here?
Question 3 - should I customize the second request to support OAuth 2.0 manually? My guess is that I need append a user token to my request. How to do that?
Thank you in advance.