APIs & Integrations

jpsanchez
Contributor | Elite Partner
Contributor | Elite Partner

JSON Correct format for checkbox options

SOLVE

Hi friends! ;,

 

just playing with ,  i export all properties from a portal and will like to impor to a new one. 

I already clean the JSON with the user create it properties. 

 

I understand that API to create a property can only work in a one call basis. So i´m stock with this load:

 

{
"name": "colectivo",
"label": "Colectivo",
"description": "",
"groupName": "propiedades_iox",
"type": "enumeration",
"fieldType": "checkbox",
"options": ["false|0|SA|null|false|-1|SA|false|0|DA|null|false|1|DA|false|0|SP|null|false|2|SP|false|0|DP|null|false|3|DP|false|null|SA DP|null|false|4|SA DP|false|null|SA DA|null|false|5|SA DA|false|null|SP DP|null|false|6|SP DP|false|null|DP SP|null|false|7|DP SP"],
"formField": "true",
"displayOrder": "-1"
}
 
Error comes from options as below.
 
{
"status": "error",
"message": "Invalid input JSON on line 8, column 25: Cannot construct instance of `com.hubspot.inbounddb.properties.views.OptionView` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('false|0|SA|null|false|-1|SA|false|0|DA|null|false|1|DA|false|0|SP|null|false|2|SP|false|0|DP|null|false|3|DP|false|null|SA DP|null|false|4|SA DP|false|null|SA DA|null|false|5|SA DA|false|null|SP DP|null|false|6|SP DP|false|null|DP SP|null|false|7|DP SP')",
"correlationId": "60d18265-3f85-4aa3-a8ee-a246d7bec977",
"requestId": "8c53ef16-2795-4590-acb5-0c54510d654c"
}
 
And i can´t find the documentation in order to transform the load. 
 
Any help will be great! 
 
KR
JP
😉
0 Upvotes
1 Accepted solution
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

JSON Correct format for checkbox options

SOLVE

Hi @jpsanchez,

 

That is right!

 

The following code works fine for me:

 

{
  "name": "nov182",
  "label": "nov 182",
  "description": "multi select picklist test",
  "groupName": "contactinformation",
  "type": "enumeration",
  "fieldType": "checkbox",
  "hidden": false,
  "options": [
    {
                "readOnly": false,
                "doubleData": 0.0,
                "description": null,
                "hidden": false,
                "label": "SA",
                "displayOrder": -1,
                "value": "SA"
    },
    {
                "readOnly": false,
                "doubleData": 0.0,
                "description": null,
                "hidden": false,
                "label": "DA",
                "displayOrder": 1,
                "value": "DA"
    },
    {
                "readOnly": false,
                "doubleData": 0.0,
                "description": null,
                "hidden": false,
                "label": "SP",
                "displayOrder": 2,
                "value": "SP"
    },
    {
                "readOnly": false,
                "doubleData": 0.0,
                "description": null,
                "hidden": false,
                "label": "DP",
                "displayOrder": 3,
                "value": "DP"
    },
    {
                "readOnly": false,
                "doubleData": null,
                "description": null,
                "hidden": false,
                "label": "SA DP",
                "displayOrder": 4,
                "value": "SA DP"
    },
    {
                "readOnly": false,
                "doubleData": null,
                "description": null,
                "hidden": false,
                "label": "SA DA",
                "displayOrder": 5,
                "value": "SA DA"
    },
    {
                "readOnly": false,
                "doubleData": null,
                "description": null,
                "hidden": false,
                "label": "SP DP",
                "displayOrder": 6,
                "value": "SP DP"

    },
    {
                "readOnly": false,
                "doubleData": null,
                "description": null,
                "hidden": false,
                "label": "DP SP",
                "displayOrder": 7,
                "value": "DP SP"
    }
  ],
  "formField": true
}

View solution in original post

0 Upvotes
4 Replies 4
WendyGoh
HubSpot Employee
HubSpot Employee

JSON Correct format for checkbox options

SOLVE

Hi @jpsanchez,

 

To clarify, are you looking to create a checkbox contact property using this endpoint: Create a contact property | Contact Properties API?

 

If so, it looks to me that the issue is with the 'options' name. This is an example of a properly formatted POST JSON for a multi-select checkboxes property:

{
  "name": "multi_pick",
  "label": "multi pick",
  "description": "multi select picklist test",
  "groupName": "contactinformation",
  "type": "enumeration",
  "fieldType": "checkbox",
  "hidden": false,
  "options": [
    {
      "label": "Option A",
      "value": "option_a"
    },
    {
      "label": "Option B",
      "value": "option_b"
    },
    {
      "label": "Option C",
      "value": "option_c"
    }
  ],
  "formField": true
}

Looking at your 'options' value,  within the array it is not storing json in the format of label and value.

 

You would need to modify it so that the 'options' value is storing json with 'label' and 'value' name in the array.

0 Upvotes
jpsanchez
Contributor | Elite Partner
Contributor | Elite Partner

JSON Correct format for checkbox options

SOLVE

Hi Wendy thanks a lot for the quick response 😉

 

Yes i see it and your example comes from the API documentation, the point is this:

 

This is the the full load when i get all properties from one portal. ( i just paste the option part from one property)

 

 "options": [
            {
                "readOnly"false,
                "doubleData"0.0,
                "description"null,
                "hidden"false,
                "label""SA",
                "displayOrder"-1,
                "value""SA"
            },
            {
                "readOnly"false,
                "doubleData"0.0,
                "description"null,
                "hidden"false,
                "label""DA",
                "displayOrder"1,
                "value""DA"
            },
            {
                "readOnly"false,
                "doubleData"0.0,
                "description"null,
                "hidden"false,
                "label""SP",
                "displayOrder"2,
                "value""SP"
            },
            {
                "readOnly"false,
                "doubleData"0.0,
                "description"null,
                "hidden"false,
                "label""DP",
                "displayOrder"3,
                "value""DP"
            },
            {
                "readOnly"false,
                "doubleData"null,
                "description"null,
                "hidden"false,
                "label""SA DP",
                "displayOrder"4,
                "value""SA DP"
            },
            {
                "readOnly"false,
                "doubleData"null,
                "description"null,
                "hidden"false,
                "label""SA DA",
                "displayOrder"5,
                "value""SA DA"
            },
            {
                "readOnly"false,
                "doubleData"null,
                "description"null,
                "hidden"false,
                "label""SP DP",
                "displayOrder"6,
                "value""SP DP"
            },
            {
                "readOnly"false,
                "doubleData"null,
                "description"null,
                "hidden"false,
                "label""DP SP",
                "displayOrder"7,
                "value""DP SP"
            }

 

 

So If i have to wrangle it. following the example

EXAMPLE

"options":

[ { "label": "Option A", "value": "option_a" }, { "label": "Option B", "value": "option_b" }, { "label": "Option C", "value": "option_c" } ],

"formField": true }

 

So it will be this?

"options"
[
            {
                "readOnly"false,
                "doubleData"0.0,
                "description"null,
                "hidden"false,
                "label""SA",
                "displayOrder"-1,
                "value""SA"
            },
            {
                "readOnly"false,
                "doubleData"0.0,
                "description"null,
                "hidden"false,
                "label""DA",
                "displayOrder"1,
                "value""DA"
            },
            {
                "readOnly"false,
                "doubleData"0.0,
                "description"null,
                "hidden"false,
                "label""SP",
                "displayOrder"2,
                "value""SP"
            },
            {
                "readOnly"false,
                "doubleData"0.0,
                "description"null,
                "hidden"false,
                "label""DP",
                "displayOrder"3,
                "value""DP"
            },
            {
                "readOnly"false,
                "doubleData"null,
                "description"null,
                "hidden"false,
                "label""SA DP",
                "displayOrder"4,
                "value""SA DP"
            },
            {
                "readOnly"false,
                "doubleData"null,
                "description"null,
                "hidden"false,
                "label""SA DA",
                "displayOrder"5,
                "value""SA DA"
            },
            {
                "readOnly"false,
                "doubleData"null,
                "description"null,
                "hidden"false,
                "label""SP DP",
                "displayOrder"6,
                "value""SP DP"
            },
            {
                "readOnly"false,
                "doubleData"null,
                "description"null,
                "hidden"false,
                "label""DP SP",
                "displayOrder"7,
                "value""DP SP"
            }
],

 

This will be correct?
_Thanks again 
JP
 
0 Upvotes
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

JSON Correct format for checkbox options

SOLVE

Hi @jpsanchez,

 

That is right!

 

The following code works fine for me:

 

{
  "name": "nov182",
  "label": "nov 182",
  "description": "multi select picklist test",
  "groupName": "contactinformation",
  "type": "enumeration",
  "fieldType": "checkbox",
  "hidden": false,
  "options": [
    {
                "readOnly": false,
                "doubleData": 0.0,
                "description": null,
                "hidden": false,
                "label": "SA",
                "displayOrder": -1,
                "value": "SA"
    },
    {
                "readOnly": false,
                "doubleData": 0.0,
                "description": null,
                "hidden": false,
                "label": "DA",
                "displayOrder": 1,
                "value": "DA"
    },
    {
                "readOnly": false,
                "doubleData": 0.0,
                "description": null,
                "hidden": false,
                "label": "SP",
                "displayOrder": 2,
                "value": "SP"
    },
    {
                "readOnly": false,
                "doubleData": 0.0,
                "description": null,
                "hidden": false,
                "label": "DP",
                "displayOrder": 3,
                "value": "DP"
    },
    {
                "readOnly": false,
                "doubleData": null,
                "description": null,
                "hidden": false,
                "label": "SA DP",
                "displayOrder": 4,
                "value": "SA DP"
    },
    {
                "readOnly": false,
                "doubleData": null,
                "description": null,
                "hidden": false,
                "label": "SA DA",
                "displayOrder": 5,
                "value": "SA DA"
    },
    {
                "readOnly": false,
                "doubleData": null,
                "description": null,
                "hidden": false,
                "label": "SP DP",
                "displayOrder": 6,
                "value": "SP DP"

    },
    {
                "readOnly": false,
                "doubleData": null,
                "description": null,
                "hidden": false,
                "label": "DP SP",
                "displayOrder": 7,
                "value": "DP SP"
    }
  ],
  "formField": true
}
0 Upvotes
jpsanchez
Contributor | Elite Partner
Contributor | Elite Partner

JSON Correct format for checkbox options

SOLVE

thanks 1000

JP

;))

0 Upvotes