2

I have this curl command:

curl -X GET --header 'Accept: application/vnd.pagerduty+json;version=2' --header 'Authorization: Token token=y_NbAkKc66ryYTWUXYEu' 'https://api.pagerduty.com/services?time_zone=UTC&sort_by=name'

I need to convert it to python using requests library

import requests

def support(self): 
    services_list = requests.get('I need to convert the link to pass it here as a parameter')
1

1 Answer 1

2
import requests

def support():
    headers = {
        'Accept': 'application/vnd.pagerduty+json;version=2',
        'Authorization': 'Token token=y_NbAkKc66ryYTWUXYEu'}

    payloads = (
        ('time_zone', 'UTC'),
        ('sort_by', 'name'),)

    services_list = requests.get('https://api.pagerduty.com/services', headers=headers, params=payloads)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.