Hi,
I’m trying to retrieve orders from my Shopify webshop using Python.
I set up the app in the admin page and retrieved API admin key. I verified that the key works because the following code is allowing me to get order information.
api_session = shopify.Session(shop_url, ‘2023-01’, api_admin)
shopify.ShopifyResource.activate_session(api_session)
However, the following code is giving me a 401 error. Can someone explain what I am doing wrong?
hostname=‘my-shop.myshopify.com’
url = [email removed]
response = requests.request(“GET”, url)
print(response)
Thanks!
Same thing if I try this:
url=‘https://my-shop.myshopify.com/admin/api/2023-04/orders.json?status=any’
headers = {‘X-Shopify-Access-Token’: api_admin}
response = requests.get(url, headers)
print(response)
any pointers as to what I’m doing wrong are welcome!
OK I did something wrong passing the authentication token to the requests.get command.
This seems to be working now, no error 401:
url=‘https://my-shop.myshopify.com/admin/api/2023-07/orders.json?status=any’
headers = {‘X-Shopify-Access-Token’: api_admin, ‘Content-Type’: ‘application/json’}
response = requests.get(url, headers=headers)