Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

I am trying to create group, after install my app. How to do with lifecycle event.?

nagaraj_deva
Contributor
July 11, 2024

Hi...
I want to create a group, once my app installed.  I have given all relevant permissions in manifest.yml.  And I have given trigger function as well.

Function gets triggered, but I'm getting forbidden error.
Can anyone help to me fix this issue?

Note : I'm able to get group details, if I use get group details API.

manifest.yml :

trigger:
    - key: lifecycle-trigger
      function: lifecycle-trigger-func
      events:
        - avi:forge:installed:app
        - avi:forge:upgraded:app
  function:
    - key: resolver
      handler: resolver.handler
    - key: lifecycle-trigger-func
      handler: lifecycle.postInstallOrUpdateHandler

Trigger this Function :

 

export const postInstallOrUpdateHandler = async (event: object, context: object) => {
  try {
    const bodyData = {
      name: 'power-users',
    };
    const response = await API.asApp().requestJira(route`/rest/api/3/group`, {
      method: 'POST',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(bodyData),
    });
    if (response.ok) {
      console.log(response);
      return await response.json();
    }
  } catch (error) {
    console.log(error);
    throw error;
  }
};

I am giving this permissions in manifest.yml
permissions:
  scopes:
    - storage:app
    - manage:jira-configuration
    - read:group:jira
    - write:group:jira

0 answers

Suggest an answer

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

Atlassian Community Events