0

Delete project property

by
Published Nov 2, 2023

Deletes the [property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties) from a project. This operation can be accessed anonymously. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the property.

Script jira
  • Submitted by hugo697 Typescript (fetch-only)
    Created 525 days ago
    1
    type Jira = {
    2
      username: string;
    3
      password: string;
    4
      domain: string;
    5
    };
    6
    /**
    7
     * Delete project property
    8
     * Deletes the [property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties) from a project.
    9
    
    
    10
    This operation can be accessed anonymously.
    11
    
    
    12
    **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the property.
    13
     */
    14
    export async function main(
    15
      auth: Jira,
    16
      projectIdOrKey: string,
    17
      propertyKey: string
    18
    ) {
    19
      const url = new URL(
    20
        `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/properties/${propertyKey}`
    21
      );
    22
    
    
    23
      const response = await fetch(url, {
    24
        method: "DELETE",
    25
        headers: {
    26
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    27
        },
    28
        body: undefined,
    29
      });
    30
      if (!response.ok) {
    31
        const text = await response.text();
    32
        throw new Error(`${response.status} ${text}`);
    33
      }
    34
      return await response.text();
    35
    }
    36