Hello,
I try to setup the hubspot PHP API and get deals using the search (V3): /crm/v3/objects/deals/search
My problem is that always when I integrate the BETWEEN operator a 400 Bad request response is returned. Without the filter it works.
In my code example I use a filter 1 (which works) and filter 2 (BETWEEN on a custom field). Filter 2 was tested with the custom field but also with a lastmodifieddate.
The customfield “datum_unterschrift” is formatted as Y-m-d and in the result without filter2 it is named and formatted exactly as expected.
Tested with lastmodifieddate using the propertyname “lastmodifieddate” as well as “hs_lastmodifieddate” with value/highvalue date with milliseconds
Error:
Exception when calling search_api->do_search: [400] Client error: `POST https://api.hubapi.com/crm/v3/objects/deals/search\` resulted in a `400 Bad Request` response: {“status”:“error”,“message”:“There was a problem with the request.”,“correlationId”:"a7d3088a-e7f5-4302-a771-ae6d5350d7f (truncated…)
Code:
$client = Factory::createWithAccessToken(config('hubspot.key'));
$filter1 = new Filter([
'value' => 'decisionmakerboughtin',
'property_name' => 'dealstage',
'operator' => 'EQ'
]);
$filter2 = new Filter([
'value' => '2023-02-01T00:00:00.000Z',
'high_value' => '2023-05-01T00:00:00.000Z',
'property_name' => 'hs_lastmodifieddate',
'operator' => 'BETWEEN'
]);
$filterGroup1 = new FilterGroup([
'filters' => [$filter1,$filter2]
]);
$publicObjectSearchRequest = new PublicObjectSearchRequest([
'filter_groups' => [$filterGroup1],
'sorts' => ['created_at'],
'properties' => ["dealname,amount,recurring_revenue_amount,dealstage,datum_unterschrift"],
'limit' => 100,
'after' => 0,
]);
Thanks