Forge App/Issue does not exist or you do not have permission to see it./get issue custom field value

Laure P April 3, 2023

Hi everyone,

I'm totally new to Forge App and i'm trying to "link" my company's own developed support issues with the jira service management issues.
In order to keep the link with those issues, I'm using a custom field which stores linked issues as JSON object.
(I wish I could set the custom field rendering as a Table, but it is not possible see https://developer.atlassian.com/platform/forge/ui-kit-components/jira/custom-field/

The view code for the custom field. Can only contain CodeImageTextTooltipTagTagGroupUser, and UserGroup components.

)
So, in order to display the linked issues with a Table, I need to get the custom field value.

For tests purposes, I've already set the custom field value with the GUI.

My problem only concerns getting this custom field value in the app.

Calling the REST API "GET https://acme.atlassian.net/rest/api/3/issue/TEST-1?fields=customfield_10045with my user PAT authentication (Administration account) with POSTMAN (Basic Authorization) gives the expected result:

{
"expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
"id": "10000",
"self": "https://acme-test.atlassian.net/rest/api/3/issue/10000",
"key": "TEST-1",
"fields": {
"customfield_10045": {
"issues": [
{
"key": "5916",
"type": "Bug",
"summary": "test",
"status": "Open"
},
{
"key": "5915",
"type": "Bug",
"summary": "test 2",
"status": "Closed"
}
]
}
}
}


While calling it through the Forge App gave me the following error message :

INFO 13:11:33.424 bca49c4f891cd049 getFieldValuesFromIssue - restUrlSearch=/rest/api/3/issue/TEST-1?fields=customfield_10045
INFO 13:11:34.679 bca49c4f891cd049 getFieldValuesFromIssue - data={"errorMessages":["Issue does not exist or you do not have permission to see it."],"errors":{}}


Here comes the permissions section in the App manifest.yml

permissions:
  scopes:
    - read:jira-work
    - read:field:jira
    - read:field-configuration:jira
    - read:issue:jira
    - read:issue-security-level:jira
    - read:jira-user # only for myself
    - read:permission:jira # only for mypermissions

In the GUI, as user, I consented to all above-mentioned permissions:
image.png

Code App extract

import api, { route } from '@forge/api';
import ForgeUI, { render, Fragment, ModalDialog, Text, Form, Link, TextField, Button, Table, Head, Row , Cell, IssuePanel, useProductContext , useState } from '@forge/ui';

...

const
App = () => {
  const prefixLog = "App - ";
  const context = useProductContext();
  //console.log(`${prefixLog}context=${JSON.stringify(context)}`);


  const issueKey = context.platformContext.issueKey;
  console.log(`${prefixLog}issueKey=${issueKey}`);


const getFieldValuesFromIssue = async (issueKey, fieldId) => {
  const prefixLog = "getFieldValuesFromIssue - ";
  const restUrlSearch = `/rest/api/3/issue/${issueKey}?fields=${fieldId}`;

//const restUrlSearch = `/rest/api/3/myself`;
  //const restUrlSearch = `/rest/api/3/mypermissions?issueKey=${issueKey}`;
  console.log(`${prefixLog}restUrlSearch=${restUrlSearch}`);
  const res = await api
  .asUser()
  .requestJira(
      route`${restUrlSearch}` ,{
        /**method: 'GET',*/
        headers: {
          'Accept': 'application/json'
        }
      }
  );

  const data = await res.json();
  console.log(`${prefixLog}data=${JSON.stringify(data)}`);  
  if((data == undefined) || (data.fields == undefined)|| (data.fields.values == undefined)){
    console.log(`${prefixLog}Unable to get values from web service`);
    if(data.errorMessages != undefined){
      setErrorMessage(`${prefixLog + JSON.stringify(data.errorMessages)}`);
    }
    return undefined;
  }

 const [errorMessage, setErrorMessage] = useState("");
 const [linkedIssues, setLinkedIssues] = useState(getFieldValuesFromIssue (issueKey,customFieldId));
console.log(`${prefixLog}linkInit=${linkedInit}`);
console.log(`${prefixLog}linkedIssues=${linkedIssues}`);

  return (    
    <Fragment>
      <Text name="error">{errorMessage}</Text>
...
    </Fragment>
);
};

 

I'm currently working with forge tunnel.

The error message is identical either with api.asApp().requestJira() or api.asUser().requestJira()

With app, calling the REST API "/rest/api/3/mypermissions?issueKey=TEST-1&permissions=BROWSE_PROJECTS,SET_ISSUE_SECURITY" with api.asApp().requestJira() or api.asUser().requestJira() provides the following error message:

INFO 13:28:25.486 b72f5ec90552bf13 getFieldValuesFromIssue - restUrlSearch=/rest/api/3/mypermissions?issueKey=TEST-1&permissions=BROWSE_PROJECTS,SET_ISSUE_SECURITY
INFO 13:28:26.694 b72f5ec90552bf13 getFieldValuesFromIssue - data={"errorMessages":["OAuth 2.0 is not enabled for method: GET /rest/api/3/mypermissions%3FissueKey=TEST-1&permissions=BROWSE_PROJECTS,SET_ISSUE_SECURITY"]}


Calling the REST API "/rest/api/3/myself" with api.asUser().requestJira() in App provides the same accountId as calling the same REST Api with POSTMAN.

Calling the "GET https://acme.atlassian.net/rest/api/3/mypermissions?issueKey=TEST-1&permissions=BROWSE_PROJECTS,SET_ISSUE_SECURITY" REST Api with POSTMAN returns the following result :

{
    "permissions": {
        "BROWSE_PROJECTS": {
            "id""10",
            "key""BROWSE_PROJECTS",
            "name""Browse Projects",
            "type""PROJECT",
            "description""Ability to browse projects and the issues within them.",
            "havePermission"true
        },
        "SET_ISSUE_SECURITY": {
            "id""26",
            "key""SET_ISSUE_SECURITY",
            "name""Set Issue Security",
            "type""PROJECT",
            "description""Ability to set the level of security on an issue so that only people in that security level can see the issue.",
            "havePermission"true
        }
    }
}


I tried with version 3 and latest REST API.

Would you be kind enough to explain me what I'm missing ?

Edit - 2023/April/03
Calling the REST API "/rest/api/3/issue/TEST-1" returns the customfield_10045 value among all the other field values.
=> [Workaround] get the issue without filtering fields...

0 answers

Suggest an answer

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

Atlassian Community Events