I am trying to cancel a fulfillment via API. Here is the API URL:
But it always returns an error like '{"errors":"An error occurred, please try again"}'
Where is the problem?
Solved! Go to the solution
Hey @nimbuspost ,
Could you provide the value of the "X-Request-ID" response header from the API response error you are retrieving? With this value we can go through our platform logs and see why this error was thrown
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
Hey @hassain,
We're seeing the same thing in our app, for the past months. The "Cancel Fulfillment" feature in our app has worked for years, but now in constantly returns 422 "An error occurred, please try again" - I believe it started around the same time the new fulfillment orders api was launched, but there has been no deprecation of the normal Fulfillment cancel endpoint.
Here are the full request headers:
HTTP POST (299.87ms) https://[REMOVED].myshopify.com:443/admin/api/2020-04/orders/2167694360623/fulfillments/2039850532911/cancel.json Request body {} HTTP response header X-Request-Id: b9fea0ef-dbf2-4fdf-bf9a-381a41dff3f702b8f6e12c0000d8913c80b200000001 Response body {"errors":"An error occurred, please try again"} Completed 500 Internal Server Error in 945ms (ActiveRecord: 1.7ms) ActiveResource::ResourceInvalid (Failed. Response code = 422. Response message = Unprocessable Entity (An error occurred, please try again).): app/controllers/home_controller.rb:382:in `cancel_fulfillment'
Any help you can provide would be much appreciated :) Thanks!
Bjorn
Hey @Bjorn_Forsberg_ ,
Would you mind re-sending the value of the X-Request-ID from the Shopify API HTTP response header? "b9fea0ef-dbf2-4fdf-bf9a-381a41dff3f702b8f6e12c0000d8913c80b200000001" does not seem to be a valid X-Request-ID.
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
@hassain Sure thing, can you please check:
X-Request-Id: fba1803f-f597-450f-8a69-2e5e57a16f88
That request was made just now :)
Thanks,
Bjorn
Hi @Bjorn_Forsberg_ ,
Thanks for sending that X-Request-ID over.
Looking through our logs, it appears the request failed because "API client cannot access this fulfillment.". I can also see that you are hitting the 2020-04 API version.
If you are using API version 2020-01 and above, you should start using FulfillmentOrders manage fulfillments on orders. I would check to make sure that your app has the proper access scopes to use FulfillmentOrders (e.g. Merchant manage fulfillment orders, assigned fulfillment orders, third party fulfillment orders, etc). Read here for more information: https://shopify.dev/tutorials/manage-fulfillments-with-fulfillment-and-fulfillmentorder-resources#ap...
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
Hey @hassain,
Thanks for the reply, and the info.. that is strange. Can you please check which permission I am missing to continue to make the same API calls.
Just FYI, I have never received or read that this endpoint was being deprecated or new permissions were needed.
I've checked the following places:
1. The Developer Changelog: https://shopify.dev/changelog?filter=api
2. The API Version Changelog: https://shopify.dev/concepts/about-apis/versioning/release-notes/2020-01 (FulfillmentOrders are added, but nothing is deprecated or removed)
3. My Partner Dashboard shows no deprecated calls for this app, even prior to upgrading to the new API version.
Can you please point me in the right direction to where this deprecation/change is documented or communicated?
Currently it looks like a breaking change was rolled out without any warning ;)
In my apps use case, where people can work in bulk of 250 orders, the FulfillmentOrders resource is not a good fit, and so I'd like to continue using the old API until it is officially deprecated.
Many thanks again,
Bjorn
Hi @Bjorn_Forsberg_ ,
Apologies, I think I was not clear in my last post and it caused confusion. FulfillmentOrders is the newest and most recommended resource for fulfilling multi location orders using API Version 2020-01 and above, but the traditional way of fulfilling an order through the Order and Fulfillments resource is still valid and working. So there is no breaking change to your app regarding fulfillments if you increase your API version for 2020-01 and 2020-04, there is just a new more recommended solution.
In terms of why you are seeing the error of "API client cannot access this fulfillment." - as long as your app has the access scopes of read_orders and write_orders you should be able to cancel the order. This error could also possibly occur if the fulfillment was created by another API Client and then your app tried to cancel their fulfillment.
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
Hi @hassain
Thanks for the follow up, and for the clarification.. that makes more sense :)
In terms of why you are seeing the error of "API client cannot access this fulfillment." - as long as your app has the access scopes of read_orders and write_orders you should be able to cancel the order. This error could also possibly occur if the fulfillment was created by another API Client and then your app tried to cancel their fulfillment.
That's the issue, my app has "read_orders" and "write_orders" scope, and the fulfillment was created by my own app. That same feature has been working fine for years, but is now always failing.
Are you able to have someone dig more into it? If you need a more recent Request-ID, then let me know and I can generate another.
Have a great Thursday!
Bjorn
This is an accepted solution.
Hey @Bjorn_Forsberg_ ,
Thanks for your patience as I have been doing some further investigation into this and playing around with my test development environment.
If you look at the Shopify REST Admin API docs for the "Fulfillment" resource, you will see that the endpoint for cancelling fulfillments has changed in version 2020-01 and above. In the 2019-10 version, it's "orders/{orderID}/fulfillments/{fulfillmentID/cancel.json" (https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillment?api[version]=...), whereas in 2020-01 it is now just simply "2020-04/fulfillments/1022782901/cancel.json" - it no longer needs any references to the "orderID" in the URL (https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillment?api[version]=...)
In order to successfully hit the `fulfillments/{fulfillment_id}/cancel.json` endpoint you need to have the read and write permissions enabled for the "fulfillment_orders" access scopes instead of the `read_orders` and `write_orders` permissions previously needed (since orders is no longer part of this call). Otherwise you will run into the error you are seeing of "The api_client does not have the required permission(s)"
If you try to access the REST Admin endpoint of `fulfillments/{fulfillment_id}/cancel.json` in API version 2019-10 and below, or try to access the REST admin endpoint of `orders/{orderID}/fulfillments/{fulfillmentID/cancel.json` in API version 2020-01 and above, you will run into errors.
Due to this, you could do any of the following actions as a work around to the issue you are facing:
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
User | Count |
---|---|
13 | |
12 | |
7 | |
4 | |
4 |