Unable to fetch contacts custom properties

$properties = [

‘email’, ‘lastname’, ‘phone’, ‘jobtitle’,

‘company’, ‘signup_date’, ‘hs_language’, ‘customer_id’,

‘referral_code’, ‘vat_id’, ‘city’

];

$response = $this->hubspot->crm()->contacts()->basicApi()->getPage(100, null, $properties);
I am trying to fetch the contacts with all their properties including custom properties, however I am only getting the default properties.

Hey, @mondersky :waving_hand: I am not a PHP expert, but I think I see one issue. You are not converting your array to a comma-separated string. This is because the Contacts API expects your properties to be sent as a param in the request URL.

I grabbed a few custom properties and did a quick test using Postman:

Request:

GET https://api.hubapi.com/crm/v3/objects/contacts/901?properties=new_mexico_chile, referrer_id, link_testerrrr

Response:

{
 "id": "901",
 "properties": {
 "createdate": "2022-11-03T21:42:31.255Z",
 "hs_object_id": "901",
 "lastmodifieddate": "2025-01-15T14:10:44.330Z",
 "link_testerrrr": "<p>123 Main St</p>\n<p><a href=\"https://www.zillow.com/\" rel=\"noopener\" target=\"_blank\">Link</a></p>",
 "new_mexico_chile": "Green",
 "referrer_id": "referrer_123"
 },
 "createdAt": "2022-11-03T21:42:31.255Z",
 "updatedAt": "2025-01-15T14:10:44.330Z",
 "archived": false
}

Here’s the code sample Postman generated for this using PHP:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
 CURLOPT_URL => 'https://api.hubapi.com/crm/v3/objects/contacts/901?properties=new_mexico_chile%2C%20referrer_id%2C%20link_testerrrr',
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_ENCODING => '',
 CURLOPT_MAXREDIRS => 10,
 CURLOPT_TIMEOUT => 0,
 CURLOPT_FOLLOWLOCATION => true,
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_CUSTOMREQUEST => 'GET',
 CURLOPT_HTTPHEADER => array(
 'Authorization: NOPE',
 'Cookie: SOME_VALUE'
 ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

If you are using the Search API and not the Contacts API, let me know.

Have fun testing! — Jaycee

using a comma separated string instead of an array seems to do the trick, thank you.
Here’s the working code:

$commaSeparatedProperties = ‘email,firstname,lastname,phone,jobtitle,company,signup_date,hs_language,customer_id,referral_code,vat_id,city’;

$response = $this->hubspot->crm()->contacts()->basicApi()->getPage(100, null, $commaSeparatedProperties);