0

I am unable to access an API.

This is what I am doing:

import os, re
import requests
import logger
from requests_oauthlib import OAuth1

oauth_consumer_key = "123abc"
oauth_secret = "aaabbbccc"

url = "https://example_testing/v1/<ID_VALUE>/reports?"

oauth = OAuth1(oauth_consumer_key, oauth_secret)

output = requests.get(url,auth=oauth)

I keep getting a 500 error.

What am I doing wrong?

1 Answers1

0

I didn't know this but apparently I needed to set values for headers and the payload. This solved my problem.

headers = {"Content-Type": "application/json"}

payload = json.dumps({
     "report_format":"csv",
     <other stuff>

}

output = requests.get(url=url, auth=oauth, headers=headers, data=payload)

Problem Solved