0

Get required status mappings for workflow scheme update

Published Nov 2, 2023

Gets the required status mappings for the desired changes to a workflow scheme. The results are provided per issue type and workflow. When updating a workflow scheme, status mappings can be provided per issue type, per workflow, or both. **[Permissions](#permissions) required:** * *Administer Jira* permission to update all, including global-scoped, workflow schemes. * *Administer projects* project permission to update project-scoped workflow schemes.

Script jira
  • Submitted by hugo697 Typescript (fetch-only)
    Created 567 days ago
    1
    type Jira = {
    2
      username: string;
    3
      password: string;
    4
      domain: string;
    5
    };
    6
    /**
    7
     * Get required status mappings for workflow scheme update
    8
     * Gets the required status mappings for the desired changes to a workflow scheme. The results are provided per issue type and workflow. When updating a workflow scheme, status mappings can be provided per issue type, per workflow, or both.
    9
    
    
    10
    **[Permissions](#permissions) required:**
    11
    
    
    12
     *  *Administer Jira* permission to update all, including global-scoped, workflow schemes.
    13
     *  *Administer projects* project permission to update project-scoped workflow schemes.
    14
     */
    15
    export async function main(
    16
      auth: Jira,
    17
      body: {
    18
        defaultWorkflowId?: string;
    19
        id: string;
    20
        workflowsForIssueTypes: { issueTypeIds: string[]; workflowId: string }[];
    21
      }
    22
    ) {
    23
      const url = new URL(
    24
        `https://${auth.domain}.atlassian.net/rest/api/2/workflowscheme/update/mappings`
    25
      );
    26
    
    
    27
      const response = await fetch(url, {
    28
        method: "POST",
    29
        headers: {
    30
          "Content-Type": "application/json",
    31
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    32
        },
    33
        body: JSON.stringify(body),
    34
      });
    35
      if (!response.ok) {
    36
        const text = await response.text();
    37
        throw new Error(`${response.status} ${text}`);
    38
      }
    39
      return await response.json();
    40
    }
    41