Discussing APIs and development related to customers, discounts, and order management.
Hi all,
I'm trying to update the "tags" of an order via below code, but I get a 403 error everytime:
def update_shopify_order(API_KEY, API_PASS, SHOP_NAME, order_id):
# connect to Shopify webshop and get draft orders
import requests
import json
headers = {"Content-Type": "application/json"}
shop_url = f"https://{API_KEY}:{API_PASS}@{SHOP_NAME}/admin"
order_url = f"/api/2021-07/orders/{order_id}.json"
data = json.dumps({"order": {"id": order_id, "tags": "invoice_created"}}).encode("utf-8")
status = requests.put(shop_url + order_url, timeout=60, data=data, headers=headers)
return status.status_code
Any idea what I might be doing wrong here?
Solved! Go to the solution
This is an accepted solution.
Update: Now it works - I think maybe updating my permissions for my private app took longer than I expected to kick into effect.
this might be obvious, but I'll ask anyway
These will be my top reason for when 403 is returned, apart from the wrong key and pass.
Hi again,
1) I've verified that the connection works by reading that particular order ID via a get request - the order exists
2) I've verified that I've enabled permissions for order editing on my private App
3) I am able to modify other things like pages/products on my webshop via similar style requests (using post, though, instead of put)
My URL looks as follows (sanitized the credentials):
https://XX:XX@shopname.myshopify.com/admin/api/2021-07/orders/3934385897661.json
This is an accepted solution.
Update: Now it works - I think maybe updating my permissions for my private app took longer than I expected to kick into effect.