0

Assign field configuration scheme to project

by
Published Nov 2, 2023

Assigns a field configuration scheme to a project. If the field configuration scheme ID is `null`, the operation assigns the default field configuration scheme. Field configuration schemes can only be assigned to classic projects. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).

Script jira
  • Submitted by hugo697 Typescript (fetch-only)
    Created 527 days ago
    1
    type Jira = {
    2
      username: string;
    3
      password: string;
    4
      domain: string;
    5
    };
    6
    /**
    7
     * Assign field configuration scheme to project
    8
     * Assigns a field configuration scheme to a project. If the field configuration scheme ID is `null`, the operation assigns the default field configuration scheme.
    9
    
    
    10
    Field configuration schemes can only be assigned to classic projects.
    11
    
    
    12
    **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
    13
     */
    14
    export async function main(
    15
      auth: Jira,
    16
      body: { fieldConfigurationSchemeId?: string; projectId: string }
    17
    ) {
    18
      const url = new URL(
    19
        `https://${auth.domain}.atlassian.net/rest/api/2/fieldconfigurationscheme/project`
    20
      );
    21
    
    
    22
      const response = await fetch(url, {
    23
        method: "PUT",
    24
        headers: {
    25
          "Content-Type": "application/json",
    26
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    27
        },
    28
        body: JSON.stringify(body),
    29
      });
    30
      if (!response.ok) {
    31
        const text = await response.text();
    32
        throw new Error(`${response.status} ${text}`);
    33
      }
    34
      return await response.json();
    35
    }
    36