Unable to update a custom property of an existing contact by email

contacts

#1

Hi,

I’m trying to update a contact by email via API. It seems that all is working fine because I’m receiving a 204 response but when I’m going to check the contact properties the updated property it’s still blank.

I copy my code below, any idea will help. Thanks.

    <?php 
             $jsonData = array(
                  'properties' => array(
                    array(
                      'property' => 'academy_last_class_viewed',
                      'vaule' => $class_title
                    )
                  )
                );
              $jsonDataEncoded = json_encode($jsonData);
              $url = 'https://api.hubapi.com/contacts/v1/contact/email/'.$user_mail.'/profile?hapikey=XXX';
              
              $ch = curl_init();
              curl_setopt($ch, CURLOPT_POST, 1);
              curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
              curl_setopt($ch, CURLOPT_URL, $url);
              curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
              $result = curl_exec($ch);
              $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
              curl_close($ch);
    ?>

#2

Hi @jSintes,

What does the final request body look like? properties should be an array of objects, like this:

{
  "properties": [
    {
      "property": "firstname",
      "value": "Updated"
    },
    {
      "property": "lastname",
      "value": "Record"
    },
    {
      "property": "website",
      "value": "http://updated.example.com"
    },
    {
      "property": "lifecyclestage",
      "value": "customer"
    }
  ]
}

#3

I hope you don't mind me hopping on this, I have the same issue.
I've added a custom Property called nps_flag this needs to be updated via API to read true if the nps is required. My first attack at this was:

https://api.hubapi.com/contacts/v1/contact/createOrUpdate/dave.nash72@gmail.com/?hapikey=

{"properties": [{"property": "firstname", "value": "Dave" },{"property": "lastname","value": "Nash"},{"property": "jobtitle","value": "Web Sys Manager"},{"property": "company","value": "ERIKS"},{"property": "website","value": "https://eriks.co.uk"},{"property": "phone","value": "+44 1246 245720"},{"property": "address","value": "Wharf Lane"},{"property": "state","value": "Derbyshire"},{"property": "zip","value": "S43 7NB"}{"property": "nps_flag","value": "True"}]}

Am I using the right API? which should I be using. Helpdesk told me Update Contact Property, however this just update the custom property not the value of the custom property


#4

Hi @dnash,

At a glance, that looks like it should work. Are you sure that the value you're setting for nps_flag exactly matches the internal value of the property? You can check in your property settings; if it's a single checkbox property, I believe the value should be true or false (i.e. lowercase).