0

Get Incident

by
Published 4 days ago

Retrieve a single incident by its ID. Use List Incidents to find IDs.

Script pagerduty Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 5 days ago
1
//native
2

3
/**
4
 * Get Incident
5
 * Retrieve a single incident by its ID. Use List Incidents to find IDs.
6
 */
7
export async function main(auth: RT.Pagerduty, incident_id: string) {
8
  const url = new URL(`https://api.pagerduty.com/incidents/${incident_id}`)
9

10
  const response = await fetch(url, {
11
    method: "GET",
12
    headers: {
13
      Authorization: `Token token=${auth.token}`,
14
      Accept: "application/vnd.pagerduty+json;version=2",
15
    },
16
  })
17

18
  if (!response.ok) {
19
    throw new Error(`${response.status} ${await response.text()}`)
20
  }
21

22
  return await response.json()
23
}
24