APIs & Integrations

IParsons
Participant

Error when posting to multiple checkbox contact field via Contacts API

Résolue

I'm getting a validation error when posting values to a multiple checkbox field using the Contacts API.

 

This is the code I'm using to post: 

 

array(
                'property' => 'allteamguids',
                'value' => str_replace(',', ';', $allTeamGUID)
            )

 

Here is the response I get from the API: 

 

{"validationResults":[{"isValid":false,"message":"28287d04-9ca8-4aa2-ad82-853248fd58e6 was not one of the allowed options: [label: \"0035139a-bc65-4fc0-bca4-371631034395\"\nvalue: \"0035139a-bc65-4fc0-bca4-371631034395\"\n, label: \"02084cca-b689-42d6-85c4-47fd83d2dca2\"\nvalue: \"02084cca-b689-42d6-85c4-47fd83d2dca2\"\n, label: \"02a1843a-5b85-4ee1-ac27-7a956d8c3980\"\nvalue: \"02a1843a-5b85-4ee1-ac27-7a956d8c3980\"\n, label: \"05078554-f6dc-443e-8921-000dc95e7b58\"\nvalue: \"05078554-f6dc-443e

 

0 Votes
1 Solution acceptée
dennisedson
Solution
Équipe de développement de HubSpot
Équipe de développement de HubSpot

Error when posting to multiple checkbox contact field via Contacts API

Résolue

You can patch the property with aptly named Properties API 😀

Test it out.  I believe you need to have all of the available values in your call when updating.  So if you sent a request with just the new value, it would remove all of the others and only have the one new value.  (I could be wrong, it has been a bit since I tested it)

Voir la solution dans l'envoi d'origine

3 Réponses
dennisedson
Équipe de développement de HubSpot
Équipe de développement de HubSpot

Error when posting to multiple checkbox contact field via Contacts API

Résolue

Hi @IParsons 

Can you confirm that that value exists in the possible property values?

0 Votes
IParsons
Participant

Error when posting to multiple checkbox contact field via Contacts API

Résolue

Hi @dennisedson - thanks for your reply. 

These values don't exist as property values - I assumed the API would create them as options if they don't exist, but I realise now that's quite a big assumption 🙂 

 

I'll go do some research, but please let me know if it's possible to create additional values through the API?  

 

0 Votes
dennisedson
Solution
Équipe de développement de HubSpot
Équipe de développement de HubSpot

Error when posting to multiple checkbox contact field via Contacts API

Résolue

You can patch the property with aptly named Properties API 😀

Test it out.  I believe you need to have all of the available values in your call when updating.  So if you sent a request with just the new value, it would remove all of the others and only have the one new value.  (I could be wrong, it has been a bit since I tested it)