I have added a new custom attribute for order in sales_order table. It contains a value for the order.

I have added extension_attributes.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
        <attribute code="custom_order_no" type="string">           

File Company\Mymodule\Api\Data\MyModuleInterface.php

namespace Company\Mymodule\Api\Data;

    interface MymoduleInterface extends \Magento\Framework\Api\CustomAttributesDataInterface
        public function getCustomOrderNo();

        public function setCustomOrderNo($custom_order_no);

        public function getExtensionAttributes();

        public function setExtensionAttributes();

If I retrieve the order with /rest/V1/orders/4 REST api call, the custom attribute is not getting displayed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.