1

In Magento2 we have rest api to get customer orders.[Route: "/rest/V1/orders"]. It can used only by admin token. I want to get customer purchased order list using customer token. I couldn't find any rest api for this. I have seen some suggestion like overriding the above api like folowing..

<route url="/V1/orders" method="GET">
    <service class="Magento\Sales\Api\OrderRepositoryInterface" method="getList"/>
    <resources>
        <resource ref="self" />
    </resources>
</route>

But I dont know how to achieve this. I just learned to create new models. I m new for magento. Can you guys please help me out?

3
  • You can refer the link for same. magento.stackexchange.com/questions/228815/… Jan 22, 2020 at 9:50
  • This is the Solution mentioned there. <route url="/V1/orders" method="GET"> <service class="Magento\Sales\Api\OrderRepositoryInterface" method="getList"/> <resources> <resource ref="self" /> </resources> </route> I have created a new model and in my webapi.xml i have added above route. But i m getting response like this. "message": "No such entity with %fieldName = %fieldValue", "parameters": { "fieldName": "orderId", "fieldValue": "1" }, Am i missing anything? Plz Correct me.
    – Joyner
    Jan 22, 2020 at 10:10
  • I have seen some other solution there. I ll check with it and update here. Thank you @KirtiNariya
    – Joyner
    Jan 22, 2020 at 10:26

1 Answer 1

0

Use a graphql query for customer.orders

https://developer.adobe.com/commerce/webapi/graphql/schema/customer/queries/customer/#retrieve-a-summary-of-the-customers-order-history

That way you can use the customer token.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.