Hello,
I am failing while sending a post request to the calculate refund endpoint. I use the “@shopify/shopify-api” module as described in the documentation and the code as follows:
const ShopifyOuter = require("@shopify/shopify-api/dist/index")
const { Shopify, DataType } = ShopifyOuter
const client = new Shopify.Clients.Rest(
`${process.env.SHOPIFY_STORE}.myshopify.com`,
process.env.SHOPIFY_SECRET
)
const calculateData = await client.post({
path: `orders/4576716390624/refunds/calculate`,
data: {
refund: {
shipping: { full_refund: true },
refund_line_items: [
{
line_item_id: 42035992527072,
quantity: 1,
restock_type: "no_restock",
},
],
},
},
type: DataType.JSON,
})
All I get as a response is this:
{ "code": 422, "statusText": "Unprocessable Entity" }
From this, I cannot figure out what the error is. I checked all these things:
- the env variables are existing and are accessible from the script (some of them are only replacement for credentials I don’t want to show)
- the order id is existing, not archived, not cancelled, not returned, not refunded, and it belongs to this store
- the order consists of the single product given in the refund_line_items
- line_item_id and quantity are numbers, no strings
- there is no difference between passing the value of the data property as a JavaScript object and as a JSON object (using JSON.stringify)
Can somebody help me to get on the right track. I appreciate any help from your side.
Stefan