blrsk
blrsk

Reputation: 345

Shopify refund API: refund_line_items.line_item can't be blank

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.

Upvotes: 1

Views: 1612

Answers (1)

Nathan Dawson
Nathan Dawson

Reputation: 19308

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.

Upvotes: 3

Related Questions