Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Failed to cancel order. Status code: 404, Response: {"errors":"Not Found"}

Failed to cancel order. Status code: 404, Response: {"errors":"Not Found"}

safwanadnan
Shopify Partner
13 0 0

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}")

 

Replies 3 (3)

Liam
Community Manager
3108 344 910

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

safwanadnan
Shopify Partner
13 0 0

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
Visitor
1 0 0

Hi, i am facing Same issue of 404, with GraphQL API and Rest admin API,
Status Code: 404
Response Text: {"errors":"Not Found"}