We are using the Cart API
to calculate shipping rates and display them on the product page.
Recently, merchants started reporting issues with shipping rate calculation. After investigating, we noticed changes in the behavior of the API.
1. Change in prepare_shipping_rates response
The request to the endpoint:
/cart/prepare_shipping_rates.json
according to the documentation should return null (and it always did in the past).
Currently, however, the endpoint returns HTTP 202 with an empty response body.
We have already adjusted our implementation to handle an empty response, so this part has been addressed on our side.
2. Issue with async_shipping_rates
At the same time, another issue started appearing, which is being reported by merchants.
When sending a request to:
/cart/async_shipping_rates.json
we receive HTTP 422 with the following response:
{
"error": [
"There was a problem calculating your shipping rates. Continue to checkout to choose a shipping rate before you complete your order."
]
}
At this point, it is unclear to us:
-
why this error is being returned,
-
and what exactly we should change to avoid it.
According to merchant reports, everything was working correctly until recently, and the issue appeared without any changes on our side.
Example requests we are making
First:
fetch('/cart/prepare_shipping_rates.json', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: '{"shipping_address":{"country":"PL","zip":"32-600"}}'
});
Then:
const params = new URLSearchParams();
params.append('shipping_address[country]', 'PL');
params.append('shipping_address[zip]', '32-600');
fetch(`/cart/async_shipping_rates.json?${params.toString()}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
Question
Have there been any recent changes to the Cart API that could affect:
-
address validation,
-
request ordering or timing,
-
expected request format,
-
or the way shipping rates are calculated?
We would appreciate any guidance on what we should verify or adjust in order to avoid the 422 error and restore the previously stable behavior.