Preconditions (*)
- Magento 2.3.1
Steps to reproduce (*)
- Create a simple code of REST API with
curl
to fetch orders with updated_at
searchCriteria parameter and fields parameter.
- Code as below
$webSiteUrl = 'mydomain.com'
$last1DayUpdated = date('Y-m-d',(strtotime ('-1 day', strtotime(date('Y-m-d')))));
$ch = curl_init("{$webSiteUrl}/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=updated_at&searchCriteria[filter_groups][0][filters][0][value]={$last1DayUpdated}&searchCriteria[filter_groups][0][filters][0][condition_type]=gteq&fields=billing_address,customer_firstname,customer_lastname");
Expected result (*)
- Output should json of orders with mentioned fields
Actual result (*)
- Output is blank array
Hi @jigardhaduk,
The way to use fields with search criteria is different, here is the code:-
$webSiteUrl = ‘mydomain.com’ $last1DayUpdated = date(‘Y-m-d’,(strtotime (‘-1 day’, strtotime(date(‘Y-m-d’))))); $ch = curl_init(“{$webSiteUrl}/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=updated_at&searchCriteria[filter_groups][0][filters][0][value]={$last1DayUpdated}&searchCriteria[filter_groups][0][filters][0][condition_type]=gteq&fields=items[billing_address,customer_firstname,customer_lastname]”);