0
votes

I am testing the Shopify API in Postman and running this request:

https://shopify.dev/docs/admin-api/rest/reference/orders/refund#calculate-2021-01

https://{{api_key}}:{{api_password}}@{{store_name}}.myshopify.com/admin/api/{{api_version}}/orders/{{order_id}}/refunds/calculate.json

with this body:

  "refund": {
    "shipping": {
      "full_refund": false
    },
    "refund_line_items": [
      {
        "line_item_id": 5843458293926,
        "quantity": 1,
        "restock_type": "no_restock"
      }
    ]
  }
}

I am getting this error:

{
    "errors": {
        "refund_line_items.line_item": [
            "can't be blank"
        ]
    }
}

I checked that all the variables I am using in the request are correct and that the "line_item_id" matches an item in the order.

1
a per documenation location id is required for type no_restockPDHide
When you say you checked that line_item_id matches an item in the order, can you confirm you checked it matches an actual line item ID and not a product or variation ID? Where did you get the line item ID from?Nathan Dawson
@NathanDawson that worked! Thanks.blrsk
@blrsk Pleased I could help. I would imagine many other people have fallen into that same trap so I've written it up as an answer for future reference.Nathan Dawson

1 Answers

1
votes

You're providing everything you need to for the endpoint in the request. The error it's returning is somewhat misleading. "Can't be blank" would suggest that you missed an argument when it's really an issue with the value you provided instead.

Line item ID is easily confused with the variety of other IDs (e.g. product or variation) that Shopify uses. You need to use the line item ID from the order. These IDs are unique to every line item of every order and not the same as the product related IDs.