I am trying to submit a POST request to the USGS EarthExplorer inventory API. This starts with a simple log-in. They have a test page:
https://earthexplorer.usgs.gov/inventory/documentation/test
which allows you to see some formatting examples. For the log-in example, I was able to extract the URL submitted on the button press as (user and pw have been changed):
However, I cannot seem to figure out how to format this in Python using the requests library. I am open to others, but am using requests for now. I have tried creating a dictionary as:
creds = {"username": "user",
"password": "pw",
"authType": "",
"catalogId": "EE"}
payload = json.dumps(creds)
When I call requests.post(url, json=payload) I am told my username parameter does not exist. I have tried other keywords like data and params as well.
I have noticed the jsonRequest parameter in the successful URL, so I tried creating a dictionary with that in there as:
creds2={"jsonRequest": [{"username": "user",
"password": "pw",
"authType": "",
"catalogId": "EE"}]}
but this doesn't work either.
Any suggestions? Thanks!