i am trying to filter contact by custom property $api_url = “https://api.hubapi.com/crm/v3/objects/contacts/search”; $data = array( “filterGroups” => array( array( “filters” => array( array( “propertyName” => “HASH”, “operator” => “EQ”, “value” => $hash ) ) ) ) ); $ch = curl_init($api_url); curl_setopt($ch, CURLOPT_USERAGENT, ‘Mozilla/4.0’); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge(self::getHeaders(), array(‘Content-Type: application/json’))); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); $response = curl_exec($ch); curl_close($ch); but i am getting an error “”"
HTTP ERROR 400
Reason:
Bad Request
Hi, @skharatyan
Thanks for your question! Dealing with 400 errors can be a bit of a challenge to investigate.
The simplest way to test your request is to use Postman to make the same request. This can allow you to verify your internal property names and other details are correct. If Postman can return a successful response, then we can move on to your PHP.
- Have you tried printing out the response body to get further information about what’s going wrong?
- Make sure that the data you’re sending is correctly encoded as JSON. Try printing the JSON-encoded $data before sending the request to check its format
- Double-check that
"HASH" is the correct internal name of the custom property
I am not a PHP user and I found some debugging examples if that is helpful:
if (!isset($hash) || empty($hash)) {
// Handle error: Hash value is not set or is empty
echo "Hash value is not set or is empty";
}
if (gettype($hash) !== 'string') {
// Handle error: Hash value is not a string
echo "Hash value is not a string";
}
echo "Hash value: " . $hash;
I hope this helps get you moving forward! — Jaycee