Question

When I try:

import requests

data = requests.get("https://api.nomi.com/api/admin/stores?v=3&k=XXXXXXX&account=XXX+XXX", verify=False)  

print data.text

I get the appropriate response.

But when I try:

import requests

payload  = {"v": "3", "k": "XXXXXXX", "account": "XXX XXX"}

data = requests.get("https://api.nomi.com/api/admin/stores?", data=payload, verify=False)  

print data.text

I get a 401 unauthorized response.

Any idea why?

Was it helpful?

Solution

You need to use the params option, not data:

data = requests.get("https://api.nomi.com/api/admin/stores", params=payload, verify=False)  

params is for the URL parameters, data is for the body (which is ignored for GET requests).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top