I have a curl POST request that returns a CSV in the terminal as expected. The following format is provided in the RJMetrcis documentation (see "Export figure data"). Here is the curl request in bash:
curl --data-raw "format=csv&includeColumnHeaders=1" -H "X-RJM-API-Key: myapikey" https://api.rjmetrics.com/0.1/figure/12345/export
Alternatively, using -d instead of --data-raw also works
However, when replicating this with the help of a previous post using requests in Python, an error is returned:
url = "https://api.rjmetrics.com/0.1/figure/12345/export"
payload = "'{\"format\":\"csv&includeColumnHeaders=1\"}'"
headers = {
'X-RJM-API-Key': 'myapikey'
}
response = requests.request("POST", url, headers=headers, params=payload)
response.text
'{"Error":"Invalid Argument: CSV is currently the only supported format for SQL Reports"}'
This is a specific error returned by the API indicating a CSV format is not requested (when -d is left out of the bash command, the same error is raised). However, both requests are syntactically the same. What could be the Python issue here? Is there a preferred method to pass parameters?