0

Retrieve the attributes of service registries

Published Mar 6, 2024

Retrieve the attributes of given service registries. **[Permissions](#permissions) required:** Only Connect apps can make this request and the servicesIds belong to the tenant you are requesting

Script jira
  • Submitted by hugo697 Typescript (fetch-only)
    Created 566 days ago
    1
    type Jira = {
    2
      username: string;
    3
      password: string;
    4
      domain: string;
    5
    };
    6
    /**
    7
     * Retrieve the attributes of service registries
    8
     * Retrieve the attributes of given service registries.
    9
    
    
    10
    **[Permissions](#permissions) required:** Only Connect apps can make this request and the servicesIds belong to the tenant you are requesting
    11
     */
    12
    export async function main(auth: Jira, serviceIds: string | undefined) {
    13
      const url = new URL(
    14
        `https://${auth.domain}.atlassian.net/rest/atlassian-connect/1/service-registry`
    15
      );
    16
      for (const [k, v] of [["serviceIds", serviceIds]]) {
    17
        if (v !== undefined && v !== "") {
    18
          url.searchParams.append(k, v);
    19
        }
    20
      }
    21
      const response = await fetch(url, {
    22
        method: "GET",
    23
        headers: {
    24
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    25
        },
    26
        body: undefined,
    27
      });
    28
      if (!response.ok) {
    29
        const text = await response.text();
    30
        throw new Error(`${response.status} ${text}`);
    31
      }
    32
      return await response.json();
    33
    }
    34