//native
/**
* Set Ticket Tags
* Replace all of a ticket's tags with the given list. Returns the ticket's new tag list.
*/
export async function main(
auth: RT.Zendesk,
ticket_id: number,
tags: string[]
) {
const response = await fetch(
`https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/tags`,
{
method: "POST",
headers: {
Authorization: auth.token
? `Bearer ${auth.token}`
: `Basic ${btoa(`${auth.username}:${auth.password}`)}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({ tags }),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago