Retrieve Entity Id from REST API using Order ID
-
27-12-2020 - |
Question
Working with the REST API on Magento 2.1.9 I notice that the Entity ID is needed for the /V1/orders/
endpoints. How can entity_id
be retrieved via the API when I only know increment_id
?
Solution
Try this -
rest/V1/orders?searchCriteria[filter_groups][2][filters][0][field]=increment_id&searchCriteria[filter_groups][2][filters][0][value]=**INCREMENT_ID_HERE**&searchCriteria[filter_groups][2][filters][0][condition_type]=eq
It should return the order details with the matching increment_id. From this you can get the order_id.
If you wanted to only return the order-Id in the request -
rest/V1/orders?searchCriteria[filter_groups][2][filters][0][field]=increment_id&searchCriteria[filter_groups][2][filters][0][value]=**INCREMENT_ID_HERE**&searchCriteria[filter_groups][2][filters][0][condition_type]=eq&fields=items[items[order_id]]
EDIT: Realised it was actualy the entity_id you wanted from this, so it would be -
rest/V1/orders?searchCriteria[filter_groups][2][filters][0][field]=increment_id&searchCriteria[filter_groups][2][filters][0][value]=INCREMENT_ID_HERE&searchCriteria[filter_groups][2][filters][0][condition_type]=eq&fields=items[entity_id]
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange