[Python] PagerDuty assignments list empty

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    How can I get "assignments" key of the incidents in PagerDuty? I have a python script which returns info on particular incident, but the list with assignments is empty.

    #!/usr/bin/env python

    import requests
    import json
    API_KEY = 'iiiiiiiiiiiiiiiiii'

    # incident ID
    ID = 'PPPPP'

    def get_incident():
    url = 'https://api.pagerduty.com/incidents/{id}'.format(id=ID)
    headers = {
    'Accept': 'application/vnd.pagerduty+json;version=2',
    'Authorization': 'Token token={token}'.format(token=API_KEY)
    }

    params = {
    'include': 'assignees',
    'time_zone': 'Europe/Sofia'
    }


    r = requests.get(url, headers=headers,data=json.dumps(params))
    print ('Status Code: {code}'.format(code=r.status_code))
    print (r.json())

    if __name__ == '__main__':
    get_incident()


    In their documentation here there are entries for that key, see on the picture bellow:

    [​IMG]

    How can I achieve that?

    Continue reading...

Compartilhe esta Página