Magento2 – Invoice Refund REST API ID Required

magento2rest api

I am using /rest/V1/invoice/{id}/refund, but it is giving error " ID required"
The json which I am posting is:

  {
  "items": [
    {
      "order_item_id": 2,
      "qty": 40
    }
  ],
  "isOnline": true,
  "notify": true,
  "appendComment": false,
  "comment": {

    "comment": "string",
    "is_visible_on_front": 0
  },
  "arguments": {
    "shipping_amount": 0,
    "adjustment_positive": 0,
    "adjustment_negative": 0,
    "extension_attributes": {
      "return_to_stock_items": [
        0
      ]
    }
  }
}

Which ID is missing?

Best Answer

Try following code:

REST API: /V1/order/:orderId/refund

Method: POST
URL: http://www.domain.com/rest/V1/order/[ORDER_ID]/refund

{
  "items": [
    {
      "order_item_id": [ORDER_ITEM_ID],
      "qty": [ORDER_ITEM_REFUND_QTY]
    }
  ],
  "notify": true,
  "arguments": {
    "shipping_amount": 0,
    "adjustment_positive": 0,
    "adjustment_negative": 0,
    "extension_attributes": {
      "return_to_stock_items": [
        [ORDER_ITEM_ID]
      ]
    }
  }
}

REST API: /V1/invoice/:invoiceId/refund

Method: POST
URL: http://www.domain.com/rest/V1/invoice/[INVOICE_ID]/refund

{
  "items": [
    {
      "order_item_id": [ORDER_ITEM_ID],
      "qty": [ORDER_ITEM_REFUND_QTY]
    }
  ],
  "is_online": false,
  "notify": true,
  "arguments": {
    "shipping_amount": 0,
    "adjustment_positive": 0,
    "adjustment_negative": 0,
    "extension_attributes": {
      "return_to_stock_items": [
        [ORDER_ITEM_ID]
      ]
    }
  }
}
Related Topic