Edits history of script submission #3610 for ' Add actors to project role (jira)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Add actors to project role
     * Adds actors to a project role for the project.
    
    To replace all actors for the project, use [Set actors for project role](#api-rest-api-2-project-projectIdOrKey-role-id-put).
    
    This operation can be accessed anonymously.
    
    **[Permissions](#permissions) required:** *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project or *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
     */
    export async function main(
      auth: Jira,
      projectIdOrKey: string,
      id: string,
      body: { group?: string[]; groupId?: string[]; user?: string[] }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/role/${id}`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 396 days ago

  • nativets
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Add actors to project role
     * Adds actors to a project role for the project.
    
    To replace all actors for the project, use [Set actors for project role](#api-rest-api-2-project-projectIdOrKey-role-id-put).
    
    This operation can be accessed anonymously.
    
    **[Permissions](#permissions) required:** *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project or *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
     */
    export async function main(
      auth: Jira,
      projectIdOrKey: string,
      id: string,
      body: { group?: string[]; groupId?: string[]; user?: string[] }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/role/${id}`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 948 days ago