Hi, How do I get the list of all resolved incidents for a specific service using the pagerduty API. I have tried the method suggested on https://community.pagerduty.com/forum/t/get-resolved-incidents-from-spesific-service/1329 but still not getting the results. Please help
Hi Anurag. Are you getting an error, or just not seeing any results? If the results are empty you might have an invalid query or some other problem.
This is a bit of bash I have that works for me, it retrieves resolved incidents over the last 30 days for one service:
TOKEN=$PD_API_KEY NOW=`date +%FT%T%z` SINCE=`date -v-30d +%FT%T%z` S_ID=("PLOSNGW") STATUSES=("resolved") ENDPOINT="/incidents?service_ids=$S_ID&since=$SINCE&until=$NOW&statuses=$STATUSES" curl -X GET --header 'Content-Type: application/json' \ --url "https://api.pagerduty.com/$ENDPOINT" \ --header 'Accept: application/vnd.pagerduty+json;version=2' \ --header "Authorization: Token token=$TOKEN"
I’m on a mac, so the options to the
date command might be different on your system.
Thanks, @mandi.walls for your help. It works for me !!