Edits history of script submission #23682 for ' Add Tag to Task (asana)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Add Tag to Task
     * Add a tag to a task. The tag must be in the task's workspace.
     */
    export async function main(auth: RT.Asana, task_gid: string, tag: string) {
      const response = await fetch(
        `https://app.asana.com/api/1.0/tasks/${task_gid}/addTag`,
        {
          method: "POST",
          headers: {
            Authorization: `Bearer ${auth.token}`,
            "Content-Type": "application/json",
            Accept: "application/json",
          },
          body: JSON.stringify({ data: { tag } }),
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 3 hours ago