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}")
Liam
August 7, 2024, 10:24am
2
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
}
}
}
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
Glouer
August 13, 2024, 7:50pm
4
Hi, i am facing Same issue of 404, with GraphQL API and Rest admin API,
Status Code: 404
Response Text: {“errors”:“Not Found”}