magentomagento2magento-rest-api

Magento 2 REST Search Orders


I am using the Magento 2 REST API. I am trying to pull a list of orders, based on the created at date. I want orders created from October 12th to October 13th. My URL sends all orders created, even ones from 2014. What is wrong with my URL?

/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=created_at&searchCriteria[filter_groups][0][filters][0][value]=2016-10-26T04:00:00.0000000Z&searchCriteria[filter_groups][0][filters][0][condition_type]=from&searchCriteria[filter_groups][0][filters][1][field]=created_at&searchCriteria[filter_groups][0][filters][1][value]=2016-10-27T03:59:00.0000000Z&searchCriteria[filter_groups][0][filters][1][condition_type]=to&searchCriteria[currentPage]=1&searchCriteria[pageSize]=100

If I omit this part, I get orders placed after the from:

/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=created_at&searchCriteria[filter_groups][0][filters][0][value]=2016-10-26T04:00:00.0000000Z&searchCriteria[filter_groups][0][filters][0][condition_type]=from


Solution

  • Here is the correct URL

    /rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=created_at&searchCriteria[filter_groups][0][filters][0][value]=2016-10-11T04:00:00.0000000Z&searchCriteria[filter_groups][0][filters][0][condition_type]=from&searchCriteria[filter_groups][1][filters][0][field]=created_at&searchCriteria[filter_groups][1][filters][0][value]=2016-10-12T03:59:00.0000000Z&searchCriteria[filter_groups][1][filters][0][condition_type]=to&searchCriteria[currentPage]=1&searchCriteria[pageSize]=100