API - https://api.pagerduty.com/analytics/raw/incidents is returning error 500

Hi,

I am trying to make a post api call for " https://api.pagerduty.com/analytics/raw/incidents" but It looks like the API is broken. I received Internal server error (500) -

{
“errors”: {
“detail”: “Internal Server Error”
}
}

Link: https://developer.pagerduty.com/api-reference/reference/REST/openapiv3.json/paths/~1analytics~1raw~1incidents/post
Topic: Analytics - Get raw data - multiple incidents

Thank you.

Could you please show us exactly what it is that you’re sending with your POST request so that we can better understand the issue here?

I’m as of yet unable to query this endpoint with my Global Admin’s user-level API key, despite passing the requisite team_ids or service_ids filter. Note, I’ve tried both with and without the [] after team_ids.

Attempt #1 Passing filter as query parameter

POST https://api.pagerduty.com/analytics/raw/incidents?team_ids=Team_ID
Accept: application/vnd.pagerduty+json;version=2
Authorization: Token token=User_API_Key
Content-Type: application/json
X-EARLY-ACCESS: analytics-v2
Raw cURL request code:
curl --request POST \
  --url 'https://api.pagerduty.com/analytics/raw/incidents?team_ids=Team_ID' \
  --header 'accept: application/vnd.pagerduty+json;version=2' \
  --header 'authorization: Token token=User_API_Key' \
  --header 'content-type: application/json' \
  --header 'user-agent: vscode-restclient' \
  --header 'x-early-access: analytics-v2'

Attempt #2 Passing filter as body parameter

POST https://api.pagerduty.com/analytics/raw/incidents
Accept: application/vnd.pagerduty+json;version=2
Authorization: Token token=User_API_Key
Content-Type: application/json
X-EARLY-ACCESS: analytics-v2

{ "team_ids": "Team_ID" }
Raw cURL request code:
curl --request POST \
  --url `https://api.pagerduty.com/analytics/raw/incidents` \
  --header 'accept: application/vnd.pagerduty+json;version=2' \
  --header 'authorization: Token token=User_API_Key' \
  --header 'content-type: application/json' \
  --header 'user-agent: vscode-restclient' \
  --header 'x-early-access: analytics-v2' \
  --data '{ "team_ids": "Team_ID" }'

Resultant output for both attempts:

{
  "errors": {
    "invalid_parameter_key": "team_ids"
  }
}

With an account-level API key and no team_ids or service_ids filter, the expected output is returned. I would expect the same behaviour with a Global Admin’s user-level API key.

I am passing the below content in the body format. Rest is all same as in the screenshot.

{"filters": {
    "created_at_start": "2020-02-02T00:00:00Z",
    "created_at_end": "2020-02-03T00:00:00Z",
    "service_ids": ["TEAM_ID"]
}}

Hi Vivek,

I have tested a similar body:

{"filters": {
"created_at_start": "2020-02-02T00:00:00Z",
"created_at_end": "2020-02-03T00:00:00Z",
"service_ids": ["service_id"]}}

and can confirm that that is the correct body.

Are you experiencing this Internal Server Error every time that you run the request, or is it an intermittent issue?

Josef

Issue still persist. To reproduce the issue, please try more than 1 service name.

{“filters”: {
“created_at_start”: “2020-02-01T00:00:00Z”,
“created_at_end”: “2020-02-03T00:00:00Z”,
“service_ids”: [“service1”, “service2”]
}}

Hello Vivek,

I have used 2 service_ids but was unable to reproduce the error. Possibly you may want to use the cURL as detailed below?

curl --location --request POST 'https://api.pagerduty.com/analytics/raw/incidents' \
--header 'Accept: application/vnd.pagerduty+json;version=2' \
--header 'Authorization: Token token=$your_token$' \
--header 'Content-Type: application/json' \
--header 'X-EARLY-ACCESS: analytics-v2' \
--data-raw '{
  "filters": {
    "created_at_start": "2020-05-01T00:00:00-04:00",
    "created_at_end": "2020-08-01T00:00:00-04:00",
    "urgency": "high",
    "major": true,
    "service_ids": [
      "PXXXXXX",
      "PXXXXXX"
    ]
}
}'

Cheers

Thanks Chiedu. I guess the issues is from the api side.

I believe I have the steps to reproduce it now. I guess PD is using cache to store service_id’s. If a service id is already present in the cache, the api returns data. When I am trying to make api call using a new service_id(this service id is never called against /analytics/raw/incidents api), it fails with internal server error. With the failure message, PD also makes an internal call and populate the cache with the service_id. So, when I make the api call again, it returns me the data.

another example I tried just now with 6 service_id’s as you can see in the image. The api call was going good till 5 service id. When I added 6th service_id(a new service id which I never used for analytics/raw/incidents api), the api returned error. Hope this should be helpful in debugging.

Have a great day.