Adding labels and API scope and 403 response

We are working on an add-on with the following scopes in atlassian-connect.json:

  "scopes": [
    "READ",
    "WRITE"
],

When we try to add labels like this:

      httpClient.post({
        url: `/wiki/rest/api/content/${pageId}/label`,
        headers: {
          //'X-Atlassian-Token': 'nocheck',
          'Accept': 'application/json',
          'Content-Type': 'application/json'
        },
        json: [ 
            {
              "prefix": "global",
              "name": "testlabel"
            }
          ]
      }, function(error, httpResponse, body) {
        if (error) {
          hlogger.error('labels error', {pageId: pageId, error: error});
          // throw
        }
        console.log(' successful:', typeof(body), body);
      });

We get a response back like:

>HTTP Status 403 – Forbidden
Request not in an authorized API scope</p><p><b>Description</b> The server understood the request but refuses to authorize it.

According to the documentation ( https://developer.atlassian.com/cloud/confluence/rest/api-group-content-labels/#api-api-content-id-label-post ), the scope should be "WRITE", and our add-on has this scope.

Any help in adding a label to Confluence content?

Classic mistake: Use Confluence url’s without the leading /wiki!

1 Like