0

Remove modules

Published Nov 2, 2023

Remove all or a list of modules registered by the calling app. **[Permissions](#permissions) required:** Only Connect apps can make this request.

Script jira
  • Submitted by hugo697 Typescript (fetch-only)
    Created 565 days ago
    1
    type Jira = {
    2
      username: string;
    3
      password: string;
    4
      domain: string;
    5
    };
    6
    /**
    7
     * Remove modules
    8
     * Remove all or a list of modules registered by the calling app.
    9
    
    
    10
    **[Permissions](#permissions) required:** Only Connect apps can make this request.
    11
     */
    12
    export async function main(auth: Jira, moduleKey: string | undefined) {
    13
      const url = new URL(
    14
        `https://${auth.domain}.atlassian.net/rest/atlassian-connect/1/app/module/dynamic`
    15
      );
    16
      for (const [k, v] of [["moduleKey", moduleKey]]) {
    17
        if (v !== undefined && v !== "") {
    18
          url.searchParams.append(k, v);
    19
        }
    20
      }
    21
      const response = await fetch(url, {
    22
        method: "DELETE",
    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.text();
    33
    }
    34