I have created an order in magento 2. And magento gave me this message
"Your order number is: 000000235. We'll email you an order confirmation with details and tracking info."
Then I tried to fetch the order details using rest api endpoint rest/V1/orders/235
in salesOrderRepositoryV1 on http://devdocs.magento.com/swagger/#/
My request as shown in screenshot,
but everytime i get this,
{
"message": "Requested entity doesn't exist"
}
Just for the reference screen shot of admin panel->sales->orders is also attached that i am fetching the details against the valid order id.
I investigated this isssue, here are some of my findings,
- This is not happening with all the orders.
- Its due to the difference between entity_id and increment_id in sales_order table.
- For most of the old orders(those i created earlier) everything is working fine but for most recent orders this issue is occuring(for which i have different entity_id and increment_id(magento gives us this id at success page)
- I need to pass in increment_id in
rest/V1/orders/{id}
but this endpoint point to entity_id in the sales_order table
Why i have difference in my entity_id and increment_id? In sales_order table i have same entity_id and increment_id for the first 165 orders(i.e entity_id = increment_id) then form entity_id 166 my increment_id became 179. Why this difference came in suddenly.
Can anyone please explain?