Magento2 – How to Get Shipping Address for Order in REST API

apimagento2ordersrestshipping-address

I can't seem to find a way to get the shipping address for an order though the REST API. Does anyone have an idea?

Best Answer

Looks like methods for retrieval of order addresses are not exposed via web API for some reason. You can expose them in you module simply by declaring in VendorName/ModuleName/etc/webapi.xml:

<?xml version="1.0"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
    <route url="/V1/orderAddresses" method="GET">
        <service class="Magento\Sales\Api\OrderAddressRepositoryInterface" method="getList"/>
        <resources>
            <resource ref="Magento_Sales::sales" />
        </resources>
    </route>
</routes>

Then use search criteria to specify filter by parent_id (as for any other list operation)