Magento 2 REST API – How to Get Order Information apicustomermagento2ordersrest I want to get order,customer information by using REST API. Anyone have idea about this? Best Answer For order information: $userData = array("username" => "admin", "password" => "admin123"); $ch = curl_init("http://magento213/index.php/rest/V1/integration/admin/token"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData)))); $token = curl_exec($ch); $ch = curl_init("http://magento213/index.php/rest/V1/orders/1"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token))); $result = curl_exec($ch); $result = json_decode($result, 1); echo '<pre>';print_r($result); Api List Related SolutionsMagento2 – How to Get Shipping Address for Order in REST API 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) Magento2 REST API – How to Get All Orders Using REST API Ideally next request must be valid to get all orders $this->get('rest/V1/orders'); But you get error instead {"message":"%fieldName is a required field.","parameters":{"fieldName":"searchCriteria"}} Error occurred because request is processed by \Magento\Sales\Api\OrderRepositoryInterface::getList(\Magento\Framework\Api\SearchCriteria $searchCriteria) and $searchCriteria argument is required. You can skip value for this parameter. Next request must be valid too. $this->get('rest/V1/orders?searchCriteria'); Related TopicMagento – Magento 2: Update order status using rest API
Best Answer
For order information:
Api List