How to expose a custom field from sales_order table to rest api?

Published On: 2 August 2018.By .
  • Digital Engineering
  • Ecommerce
  • General

Suppose you have custom field delivery_type in sales_order table.  You are accessing order using rest Api but this field is not present in response.

Requested Api: http://localhost/default/rest/default/V1/orders/{order_id}

You can get it working for individual order. Though if you want to show this attribute in order collection as well you have to modify getList method also.

You have to create custom module. 

If you follow link to create new custom module.

etc/extension_attributes.xml

etc/webapi_rest/di.xml

Plugin/Api/OrderRepository.php

 

Related content

That’s all for this blog