0

Get project property keys

by
Published Nov 2, 2023

Returns all [project property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties) keys for the project. This operation can be accessed anonymously. **[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.

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
     * Get project property keys
    8
     * Returns all [project property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties) keys for the project.
    9
    
    
    10
    This operation can be accessed anonymously.
    11
    
    
    12
    **[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
    13
     */
    14
    export async function main(auth: Jira, projectIdOrKey: string) {
    15
      const url = new URL(
    16
        `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/properties`
    17
      );
    18
    
    
    19
      const response = await fetch(url, {
    20
        method: "GET",
    21
        headers: {
    22
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    23
        },
    24
        body: undefined,
    25
      });
    26
      if (!response.ok) {
    27
        const text = await response.text();
    28
        throw new Error(`${response.status} ${text}`);
    29
      }
    30
      return await response.json();
    31
    }
    32