-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consumer Order Rest API #3552
Comments
I believe the two API's are /rest/V1/orders/:id to get the details one the customer's orders or /rest/V1/orders to get all the orders related to that customer. If you want to build a quote object and submit that as a customer you should be using the /rest/V1/carts/mine/ series of APIs. If you have further questions - please ask on our Forums. |
Thanks choukalos for quinck reply. |
For specific customer you have to pass customer email parameter in api. and pass admin Bearer key instead customer Bearer key |
In my opinion it seems that the customer authentication should to suffice to return a list of orders for the authenticated Customer. |
@choukalos can you reopen this issue? This is real problem with bad REST API design. There is no option to get all customer orders without setting there admin rights. So can you create api call like /V1/orders/me/items ? @develpr did you solve this? |
I have the same problem. If you are working in a Web App Client for Magento2, I do not want to a admin token for security reason. Anybody have some idea/opinion about it and how solve it? |
@RUjmiak I ended up writing my own endpoint, which was fairly easy overall. But yeah, no official updates that I'm aware of :( |
I'm learning about Magento 2. I'm trying create my own endpoint to using this tutorial :) http://www.ipragmatech.com/extend-magento2-rest-api-easy-steps/ |
@develpr can you share it with others? :) |
Sure, let me put something together @RUjmiak |
Is there any progress on this? Can you share your solution @develpr , please? |
I am suffer from this problem. Any body have a solution? |
Sorry I never ended up pasting code, the truth is there just isn't that much to it. That said, here are the basic steps:
Then you would of course need an Finally, in the concrete method signature:
body
Note that this is basically the same code that admin version of the repository does, but I added the customer filter to filter the orders returned by customer ID. Alternatively, you could implement that method the way that the "normal" FE logic does it, by injecting a
I don't know, that might be "safer" (?) but the first method works well in my (somewhat limited!) testing. |
@develpr , Thanks for help, but can you share the full answer files on an organized well. I am new to magento.? |
@slimzc , I followed the steps in the link you shared, It is returning all the orders for a specific customer, Ho can I return orders with a specific status(pending, complete) ? |
@msliman, I have tried with API filters in parameters or put a "if" in the endpoint implementation (Order.php in the model)? |
@slimzc I made some changes and working fine. thank you. |
is there any update regarding fetching the orders list of customer via REST API? i am also getting error , consumer Consumer is not authorized to access Magento_Sales::sales |
is there any update regarding fetching the orders list of customer via REST API? i am also getting error , consumer Consumer is not authorized to access Magento_Sales::sales.Please tell me solution i have same error. |
[PANDA] [B2B] Unable to add large catalog to shared catalog & Cover new customer addresses grid by MFTF tests
Why this merge request referenced this issue. I've took a look at it and notting fix this issue in it. |
Here is a very small tutorial to make this work (thanks to @develpr for pointing me in the right direction). Create a module with the normal module stuff, let's call it Vendor_MyOrders. Create a directory called Api and within it an interface named OrderInterface. Code would be : `
} Creat a di.xml with the following line: next, create the Order file and use the $userContext to get the user (this is a bit saver then using a customerId), here is the code: `use Vendor\MyOrders\Api\OrderInterface; class Order implements OrderInterface
}` now all we need is a webapi.xml (in the etc directory!) that tells the consumer where to get his/her order:
` That is it. |
We are using the Magento 2 REST API. We are able to access the the orders using the admin token. But we are unable to access the orders using consumer.
Below is the API which I am using:
Get Orders : /rest/V1/orders/items But I am getting the error that Consumer is not authorized to access %resources even I have passed the consumer key in my header.
Is the customer orders REST api is implemented ?
The text was updated successfully, but these errors were encountered: