Shopify Refund API Error

Solved
UsamaIlyas
Tourist
6 1 0

Hi,

We are posting a refund to this Endpoint

/admin/orders/2186660184112/refunds.json

And we are using this Payload

{
    "refund": {
        "currency""USD",
    "restock"true,
        "notify"true,
        "note""Return Testing",
        "shipping": {
            "full_refund"false
        },
        "refund_line_items": [
            {
                "line_item_id"4725473411120,
                "quantity"1
            }
        ],
        "transactions": [
            {
                "parent_id"2759902363696,
                "amount""0.5",
                "kind""refund",
                "gateway""stripe"
            }
        ]
    }
}

 
But from Code we are getting Error 
Error code 422 Unprocessable Entity (An error occurred, please try again)
 
And when we try from Post Man a link is generated and there is no information in it. it just opens up the Shopify Dashboard after login.
 
 
0 Likes
Greg_Kujawa
Shopify Partner
951 79 203

Here are the current docs for this API endpoint --> https://shopify.dev/docs/admin-api/rest/reference/orders/refund?api[version]=2020-04#create-2020-04. Depending on which API version you are using, I'd recommend checking the JSON request body you are sending. For example, the refund_line_items can contain restock_type and location_id properties. And if the shipping's full_refund is false you might have to specify an amount... 

0 Likes
UsamaIlyas
Tourist
6 1 0

Hi,

I have tried with this Endpoint /admin/api/2020-04/orders/2186660184112/refunds.json

and JSON


{
    "refund": {
        "currency""USD",
        "notify"true,
        "note""Return Testing",
        "shipping": {
            "full_refund"true
        },
        "refund_line_items": [
            {
                "line_item_id"4725473411120,
                "quantity"1,
                "restock_type""return",
                "location_id"280092097
            }
        ],
        "transactions": [
            {
                "parent_id"2759902363696,
                "amount""1.5",
                "kind""refund",
                "gateway""stripe"
            }
        ]
    }
}
Using this payload it is still not working
Also can you please guide,
    "transactions": [
            {
                "parent_id"2759902363696,
 
In the parent_id we have have to pass on the parent_id  from the transaction EndPoint
 
EndPoint: admin/orders/2186660184112/transactions.json

Thanks
0 Likes
UsamaIlyas
Tourist
6 1 0

And the Error is from Code

The remote server returned an error: (422) Unprocessable Entity.

0 Likes
UsamaIlyas
Tourist
6 1 0

This is an accepted solution.

Hi,

The Strange thing is Return was created successfully but received the Error response, I only came to know the return is created, when I had checked by GET Endpoint.

 

Thank

0 Likes