mfcss
1
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?
1 Like
Bunty
2
this might be obvious, but I’ll ask anyway
- Is the private app installed on the shop?
- Does {SHOP_NAME} include .myshopify.com?
- Does that order exist?
These will be my top reason for when 403 is returned, apart from the wrong key and pass.
mfcss
3
Hi again,
-
I’ve verified that the connection works by reading that particular order ID via a get request - the order exists
-
I’ve verified that I’ve enabled permissions for order editing on my private App
-
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
mfcss
4
Update: Now it works - I think maybe updating my permissions for my private app took longer than I expected to kick into effect.
2 Likes