Cannot cancel order with API with Order ID

dribeirofernand
New Member
1 0 0

API call = https://{Username}:{Password}@{ShopURL}/admin/api/2020-10/orders/{orderID}/cancel.json
When I try to cancel an order with a given OrderID the API responds with:
{"errors":"Not found"}
The OrderID is obtained from  the order itself which is fetched from the API as well.


The code is currently like this (formatted as ruby, shopify forums don't have C# as an option):

 

# Call to the Shopify API (Cancel order from ID)
 string APICall = $"https://{Username}:{Password}@{ShopURL}/admin/api/2020-10/orders/{orderID}/cancel.json";

# Cancel the order
RestClient client = new RestClient(APICall);
RestRequest request = new RestRequest(Method.POST);
request.AddHeader("X-Shopify-Access-Token", Password);
var response = client.Post(request);

 

 

I'm using C# and RestSharp to POST.

With the same orderID I can DELETE the order, but cancelling just returns the error aforementioned.

0 Likes