2

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?

1

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]

  • Thanks - although I found the solution a while ago, should have checked back on SE immediately! – kemika Jan 18 '18 at 16:26
  • @all, I can't get order increment_id by this code. Can you post/comment your full code? It will be great help for others. – Jigar Dhaduk Jul 6 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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