Adding Organizations to a Project via Forge

I have an app (Forge Webtrigger) attempting to create an Organization and add it to a service desk project.

This involves 2 calls that I am executing asApp():

  1. Creating the Org - this works.
// Create new Organization
await api.asApp().requestJira(route`/rest/servicedeskapi/organization`, {
  method: "POST",
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: name
  })
});
  1. Adding the Org to a project - this is failing.
// Add Organization to Project
await api.asApp().requestJira(route`/rest/servicedeskapi/servicedesk/${project}/organization`, {
  method: "POST",
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    organizationId: org_id
  })
});

Docs:
https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-organization/#api-rest-servicedeskapi-servicedesk-servicedeskid-organization-post
According to the API docs, both calls ask for the manage:servicedesk-customer scope, which my app has.

Adding the new Organization to a project results in the following error:

{
   "errorMessage":"You'll need additional permission to manage organizations",
   "i18nErrorMessage":{
      "i18nKey":"sd.customer.organisation.error.manage.organisation.permission.violation",
      "parameters":[
         
      ]
   }
}

Is there an additional scope needed on top of manage:servicedesk-customer? Or, what is the reason for this error?

Hi there,

just for the record: you use the serviceDeskId for ${project} in your code, right? serviceDeskId != projectId.

Cheers,
paul

Hi Paul,

I have tested both but it is the same result either way.

Via regular API, both of the below work:

  • /rest/servicedeskapi/servicedesk/ABC/organization
  • /rest/servicedeskapi/servicedesk/2/organization

But in Forge, both produce the same error shown in the initial post.

1 Like