Development discussions around Shopify APIs
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:
Can somebody help me to get on the right track. I appreciate any help from your side.
Stefan
Solved! Go to the solution
This is an accepted solution.
Hello again,
I finally managed it to find the reason for the failure. The line_item_id I have to provide is something I have to take from the original order data. It is neither the product ID nor the variant ID which is usually taken for checkout links.
I visualized the response of a request for a certain order to make clear, which ID to use.
{
"line_items": [
{
"id": xxxxxxxxx <-- This is the ID to use to describe a returned product!
}
]
}
Thank you for your help although no one found the solution to my problem before me.
Stefan
This is an accepted solution.
Hello again,
I finally managed it to find the reason for the failure. The line_item_id I have to provide is something I have to take from the original order data. It is neither the product ID nor the variant ID which is usually taken for checkout links.
I visualized the response of a request for a certain order to make clear, which ID to use.
{
"line_items": [
{
"id": xxxxxxxxx <-- This is the ID to use to describe a returned product!
}
]
}
Thank you for your help although no one found the solution to my problem before me.
Stefan
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023