APIs & Integrations

pquinta
Participante

Updating a contact property via API

resolver

Hi there, 

 

I am trying to update a contact property via API, but I am getting errors constantly and I am not finding any help in the documentation. As such, the property in question has the following characteristics:

 

Its a multiple checkboxes property named Tags

 

My goal is to create a new checkbox item in the property ( I know that by adding one i erased the current ones)

What I am sending:

 

'https://api.hubapi.com/properties/v1/contacts/properties/named/tags?hapikey=xxxx',
                    {
                        'Content-type': 'application/json'
                    },
                    {
                        "name": "tags",
                        "groupName": "xpto_information",
                        "description": "",
                        "fieldType": "checkbox",
                        "formField": False,
                        "type": "enumeration",
                        "displayOrder": -1,
                        "label": "Tags",
                        "options": [
                            {
                                "label": "TestA",
                                "displayOrder": -1,
                                "hidden": False,
                                "readOnly": False,
                                "doubleData": False,
                                "description": False,
                                "value": "TestA"
                            }
                        ]
                    }

I am getting a 400 error invalid JSON input and cannot deserialize .....

0 Me gusta
1 Soluciones aceptada
jackcoldrick
Solución
HubSpot Employee
HubSpot Employee

Updating a contact property via API

resolver

Hi @pquinta ,

In your payload I would recommend setting "doubleData" to null and also to ensure you are passing "false" instead of "False". For example I am able to successfully update a property using the payload below:

 

{
    "name": "tags",
    "description": "",
    "groupName": "contactinformation",
    "type": "enumeration",
    "fieldType": "checkbox",
    "formField": true,
    "options": [
        {
            "label": "TestA",
            "displayOrder": -1,
            "hidden": false,
            "readOnly": false,
            "doubleData": null,
            "description": "false",
            "value": "TestA"
        },
        {
            "label": "TestB",
            "displayOrder": -1,
            "hidden": false,
            "readOnly": false,
            "doubleData": null,
            "description": "false",
            "value": "TestB"
        }
    ],
    "createdUserId": null,
    "searchableInGlobalSearch": false
}

Which results in this property being updated in my portal:

tags.png

 

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn

Ver la solución en mensaje original publicado

3 Respuestas 3
jackcoldrick
Solución
HubSpot Employee
HubSpot Employee

Updating a contact property via API

resolver

Hi @pquinta ,

In your payload I would recommend setting "doubleData" to null and also to ensure you are passing "false" instead of "False". For example I am able to successfully update a property using the payload below:

 

{
    "name": "tags",
    "description": "",
    "groupName": "contactinformation",
    "type": "enumeration",
    "fieldType": "checkbox",
    "formField": true,
    "options": [
        {
            "label": "TestA",
            "displayOrder": -1,
            "hidden": false,
            "readOnly": false,
            "doubleData": null,
            "description": "false",
            "value": "TestA"
        },
        {
            "label": "TestB",
            "displayOrder": -1,
            "hidden": false,
            "readOnly": false,
            "doubleData": null,
            "description": "false",
            "value": "TestB"
        }
    ],
    "createdUserId": null,
    "searchableInGlobalSearch": false
}

Which results in this property being updated in my portal:

tags.png

 

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn
pquinta
Participante

Updating a contact property via API

resolver

Thanks a lot @jackcoldrick . It works now.

As I was using python I unconsciously replaced false with False and yeah almost certain that it was causing trouble.

jackcoldrick
HubSpot Employee
HubSpot Employee

Updating a contact property via API

resolver

No worries @pquinta happy to help! 🙂 

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn
0 Me gusta