Cannot remove label from confluence page through Forge

When going through the Confluence REST API, I see you can remove a label from a confluence page through https://developer.atlassian.com/cloud/confluence/rest/api-group-content-labels/#api-wiki-rest-api-content-id-label-label-delete

When trying this through postman, this seems to work with both methods:


When trying this in Forge with both methods, I get 2 different behaviors:

export const removeConfluenceLabel = async (contentId: string, label: string) => {
    const res = await api
      .asApp()
      .requestConfluence(route`/wiki/rest/api/content/${contentId}/label/${label}`, {
          methode: 'DELETE'
      });

    if (!res.ok) {
      console.log(`${JSON.stringify(res)}`)
      return {};
    }

    return await res.json();
};

Gives me an unauthorized response, even though I have the permissions:

permissions:
  scopes:
    - storage:app
    - read:confluence-content.summary
    - read:confluence-props
    - write:confluence-props
    - write:confluence-content
    - write:label:confluence
    - read:jira-work
    - write:jira-work
    - manage:jira-project

And with

export const removeConfluenceLabel = async (contentId: string, label: string) => {
  console.log(`/wiki/rest/api/content/${contentId}/label?name=${label}`)
  const res = await api
    .asApp()
    .requestConfluence(route`/wiki/rest/api/content/${contentId}/label?name=${label}`, {
      methode: 'DELETE'
    });

  if (!res.ok) {
    console.log(`NOK = ${JSON.stringify(res)}`)
    return {};
  }
  console.log(`OK = ${JSON.stringify(res)}`)

  return await res.json();
};

I don’t get any error report and it gives me the 200 all OK BUT the label is not removed.

What am I doing wrong?

Thank you very much in advance,

Kind regards,

Tim

I suspect that it’s not working as you have typo in the method - you have methode in your code which I guess results in sending GET request.

1 Like

Of course, thank you for noticing this. Sorry … it seems my Dutch got in the way :wink:

1 Like