I’m trying to filter orders by date using the Magento REST API (/rest/V1/orders). I want to get orders from a given date range.
The API works perfectly fine with basic search criteria (without filters), but throws a signature invalid error when I add date filters.
Here’s what works (returns orders successfully):
$searchCriteriaArray = [
'searchCriteria' => [
'currentPage' => 1,
'pageSize' => 10
]
];
I’ve tried the following approaches to add date filters, but all result in a signature invalid error:
Using filterGroups with condition_type:
$searchCriteriaArray = [
'searchCriteria' => [
'currentPage' => 1,
'pageSize' => 10,
'filterGroups' => [
0 => [
'filters' => [
0 => [
'field' => 'created_at',
'value' => '2024-01-01',
'condition_type' => 'gteq'
]
]
]
]
]
];
Using camelCase conditionType:
$searchCriteriaArray = [
'searchCriteria' => [
'filterGroups' => [
0 => [
'filters' => [
0 => [
'field' => 'created_at',
'value' => '2024-01-01',
'conditionType' => 'gteq'
]
]
]
],
'currentPage' => 1,
'pageSize' => 10
]
];
Using flat structure:
$searchCriteriaArray = [
'searchCriteria[currentPage]' => 1,
'searchCriteria[pageSize]' => 10,
'searchCriteria[filter][0][field]' => 'created_at',
'searchCriteria[filter][0][value]' => '2024-01-01',
'searchCriteria[filter][0][condition_type]' => 'gteq'
];
I’m encoding the parameters using this code:
$baseUrl = 'https://mydomain.com';
$endpoint = '/rest/V1/orders';
$queryString = http_build_query($searchCriteriaArray);
$url = $baseUrl . $endpoint . '?' . $queryString;
// oAuth code
All attempts with filters result in:
{"message":"The signature is invalid. Verify and try again."}
I’ve tried:
- Different date formats (with/without time)
- Different condition types (gt, gteq, from, after)
- Different array structures
- Different field names (created_at, updated_at)
Has anyone successfully implemented date filtering with the orders API? What am I missing?
Thanks in advance for any help!