UI manipulation through an app

I have created a forge application that allows scripted comments to be added to the user story from within the ui but afterwards I would like to remove the custom app box from the issue and refresh the comments to show the new additions. I am trying to get the custom app properties with the /rest/api/1/issue/${issue.key}/properties/{app.key} but I keep getting an error 1. “OAuth 2.0 is not enabled for method: GET /rest/api/1/issue/AL-1/properties/agilist-ui”

my response is const response = await api .asUser() .requestJira(route/rest/api/1/issue/${issue.key}/properties/agilist-ui, { headers: { Accept: 'application/json', }, });

My permissions for the app are: permissions: scopes: - write:jira-work - write:issue.property:jira - read:issue.property:jira - read:jira-work - manage:jira-configuration

Hi @CharlieTupman ,

Welcome to the Atlassian Developer Community.

It looks like you’re attempting to use an old version of the REST API. Try either GET /rest/api/2/issue/{issueIdOrKey}/properties/{propertyKey} or GET /rest/api/3/issue/{issueIdOrKey}/properties/{propertyKey}.

The main differences between the V2 and V3 Jira REST APIs is that V3 is still in beta because it uses the Atlassian Document Format (ADF), but there are certain limitations with ADF such as insufficient parsing support, etc.

Regards,
Dugald

Hi @dmorrow I have tried all 3 versions and I’m still getting the same response - Oauth errors. Do I need to be using uiModifications and if so how? Would be really helpful to know best practices for wanting to do something like this. So far I have scoured the documentation and am unable to see how its done.

Hi @CharlieTupman ,

When you call the version 3 API, ie. /rest/api/3/issue/{issueIdOrKey}/properties/agilist-ui, is the error exactly the same as posted, ie. “OAuth 2.0 is not enabled for method”?

If it’s slightly different in any way, can you please post it here? I see you’ve specified read:jira-work, which should be enough permission.

Hi @CharlieTupman ,

Here is some sample code that I tested earlier today:

manifest.yml:

modules:
  jira:issuePanel:
    - key: forge-get-issue-property-demo-hello-world-panel
      function: main
      title: Forge get issue property demo
      icon: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg
  function:
    - key: main
      handler: index.run
permissions:
  scopes:
    - 'read:jira-work'
app:
  id: ari:cloud:ecosystem::app/.....

index.jsx:

import ForgeUI, { Code, render, Fragment, Text, IssuePanel, useAction, useProductContext } from '@forge/ui';
import api, { route } from "@forge/api";

const App = () => {

  const myIssuePropertyKey = 'issue.content.panel.customised.flag';

  const fetchIssueProperty = async (issueIdOrKey, propertyKey) => {
    const res = await api
      .asUser()
      .requestJira(route`/rest/api/3/issue/${issueIdOrKey}/properties/${propertyKey}`);
    const data = await res.json();
    return data;
  };

  const fetchMyIssueProperty = async () => {
    const context = useProductContext();
    return await fetchIssueProperty(context.platformContext.issueKey, myIssuePropertyKey);
  }

  const [myIssueProperty] = useAction(value => value, async () => await fetchMyIssueProperty());

  return (
    <Fragment>
      <Text>
        My issue property:
        <Code text={JSON.stringify(myIssueProperty, null, 2)} />
      </Text>
    </Fragment>
  );
};

export const run = render(
  <IssuePanel>
    <App />
  </IssuePanel>
);

Regards,
Dugald