I have an API I am accessing using the python requests
package. When the data set requested exceeds an internal size limit, the standard endpoint will return a failure and the response code indicates to use their "export" endpoint which serves a CSV instead.
However, the returned CSV data is, what appears to be to me, an encoded string.
Here is an example of the output (trimmed to show start and end)
{"Data":"VGVybWluYWwgTnVtsQ2FsZW5kYXIgVGltZSxUcmFuc2FjdGlvbiBUeXBlLE...GhvbGRlciB0cmFuc2FjdGlvbiIsIkRlbmllZCI="}
What I've tried so far is extracting the string, and then tried various encode/decode combinations, but nothing is yielding a human readable CSV.
The response headers are:
{'Content-Length': '556895',
'Content-Type': 'application/json; charset=utf-8',
'Server': 'Microsoft-HTTPAPI/2.0',
'Date': 'Fri, 24 Apr 2020 17:13:31 GMT'}
Does anyone have experience with this? I expected a byte-string or a byte array, but this is just a utf-8 string.
I apologize if this is something simple I am overlooking, or if I have left out crucial information.
EDIT: My request looks like this:
api = myAPIObject()
api.authenticate(username, passwd)
CR_ID = 5341345
res = requests.post(api.CR_export_url,
headers=api.auth_header,
data={'ID': CR_ID,
'ExportFormat': 'CSV',
'ShouldIncludeHeaders':True})
This is per the documentation of the api.