Edits history of script submission #23381 for ' Get Task (jira)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get Task
     * Get the status and progress of a long-running asynchronous task (e.g. a bulk operation) by its task ID.
     */
    export async function main(auth: RT.Jira, task_id: string) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/3/task/${task_id}`
      )
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: `Basic ${btoa(`${auth.username}:${auth.password}`)}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 8 days ago