Discussing APIs and development related to customers, discounts, and order management.
I am using the REST admin API to cancel orders but it continues to return the following error:
{"errors":"Not Found"}
The order does exist as I can find it using the orders API and even visible in my dashboard. Here's my code:
import requests store_url = "" access_token = "" order_id = "6009742098749" url = f"{store_url}/admin/api/2024-07/orders/{order_id}/cancel.json?restock=true" headers = { "X-Shopify-Access-Token": access_token, "Content-Type": "application/json" } response = requests.post(url, headers=headers, json={}) if response.status_code == 200: print("Order cancelled successfully.") else: print(f"Failed to cancel order. Status code: {response.status_code}, Response: {response.text}")
If you try the same action with the GraphQL API orderCancel mutation , (you can use the graphiql app to test) do you also see an error, eg:
mutation CancelOrder {
orderCancel(
orderId: "gid://shopify/Order/6009742098749",
reason: CUSTOMER,
refund: true,
restock: true,
notifyCustomer: true,
staffNote: "Customer requested cancellation"
) {
job {
done
id
}
orderCancelUserErrors {
code
field
message
}
}
}
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
The problem is I can't use the GraphQL API at all. All permission scopes are allowed, works like a charm on the app but wouldn't work using the API no matter what I try. Please figure it out for me
Hi, i am facing Same issue of 404, with GraphQL API and Rest admin API,
Status Code: 404
Response Text: {"errors":"Not Found"}