APIs & Integrations

byersoy
Member

How do add new data in option select property use to api?

SOLVE

I want to add a new option but I need to do this using api.

 

https://developers.hubspot.com/docs/methods/contacts/v2/update_contact_property at don't add a new option.

0 Upvotes
2 Accepted solutions
JasminLin
Solution
HubSpot Employee
HubSpot Employee

How do add new data in option select property use to api?

SOLVE

@byersoy Just to clarify, if you are using this endpoint https://developers.hubspot.com/docs/methods/contacts/v2/update_contact_property the method should be PUT, but if you are using this endpoint https://developers.hubspot.com/docs/methods/companies/get_contact_property the method should be GET. 

 

If you are still facing issues despite using the correct method for the endpoint, could you direct message me the following:

  1. A full screenshot of your Postman app where you attempted the endpoint
  2. The API endpoint URL you are calling
  3. The method you are using
  4. The request body you are sending (for the PUT request)

View solution in original post

0 Upvotes
Mike_Eastwood
Solution
Recognized Expert | Gold Partner
Recognized Expert | Gold Partner

How do add new data in option select property use to api?

SOLVE

Hi @DiogoMC 

 

You prepend the value with a semi-colon to add a values, keeping the original value.

 

Assuming you have a multiselect checkbox with the options available:

  • Marketing Hub <marketing_hub>
  • Sales Hub <sales_hub>
  • Service Hub <service_hub>
  • CMS Hub <cms_hub>

For this example asssume Marketing Hub is already Selected

 

This adds to the current selection because the semicolon at the start so the field now has Marketing Hub, Sales Hub and Service Hub.

 

;sales_hub;service_hub

 

 

This clears Marketing Hub (because there's no semicolon at the start) and sets Sales Hub and Service Hub.

 

sales_hub;service_hub

 

You can NOT set Ops Hub <ops_hub> because the value isn't available in the Property (the API will throw an error).

 

Did that answer your question?

Mike

 

View solution in original post

12 Replies 12
JasminLin
HubSpot Employee
HubSpot Employee

How do add new data in option select property use to api?

SOLVE

Hey @byersoy , are you referring to adding a new option to an enumeration type property? If so, you are looking at the correct documentation https://developers.hubspot.com/docs/methods/contacts/v2/update_contact_property - to update your enumeration property with a new option, you need to include all of the existing options and your new option in the request payload. 

 

You can get the existing options in the enumeration property by using this GET request https://developers.hubspot.com/docs/methods/companies/get_contact_property

0 Upvotes
byersoy
Member

How do add new data in option select property use to api?

SOLVE

@JasminLin thx for reply,

 

Bu not working this solution.


Return error with postman:

 

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
        <title>Error 405 Method Not Allowed</title>
    </head>
    <body>
        <h2>HTTP ERROR 405</h2>
        <p>Problem accessing /properties/v2/contact/properties/named/multi_pick_test_7. Reason:

            <pre>    Method Not Allowed</pre>
        </p>
    </body>
</html>
0 Upvotes
JasminLin
HubSpot Employee
HubSpot Employee

How do add new data in option select property use to api?

SOLVE

Hey @byersoy , the error 405 Method Not Allowed typically refers to the HTTP method used to call the endpoint. If you are attempting to use this endpoint https://developers.hubspot.com/docs/methods/companies/get_contact_property can you confirm if you are using the GET method? 

0 Upvotes
byersoy
Member

How do add new data in option select property use to api?

SOLVE

Yes @JasminLin i use get method 😞

 

Can you send a sample with Postman if you ask?

0 Upvotes
JasminLin
Solution
HubSpot Employee
HubSpot Employee

How do add new data in option select property use to api?

SOLVE

@byersoy Just to clarify, if you are using this endpoint https://developers.hubspot.com/docs/methods/contacts/v2/update_contact_property the method should be PUT, but if you are using this endpoint https://developers.hubspot.com/docs/methods/companies/get_contact_property the method should be GET. 

 

If you are still facing issues despite using the correct method for the endpoint, could you direct message me the following:

  1. A full screenshot of your Postman app where you attempted the endpoint
  2. The API endpoint URL you are calling
  3. The method you are using
  4. The request body you are sending (for the PUT request)
0 Upvotes
byersoy
Member

How do add new data in option select property use to api?

SOLVE

Thx all reply,

 

I worked but this not add new option, change all option.

 

Put Method: https://api.hubapi.com/properties/v1/contacts/properties/named/DROPDOWNSELECTNAME?hapikey=KEY

 

{
    "name": "dropdownselectname",
    "label": "Dropdown Select Test 1",
    "groupName": "contactinformation",
    "type": "enumeration",
    "fieldType": "select",
    "options": [
        {
            "label": "test1",
            "displayOrder": -1,
            "hidden": false,
            "readOnly": false,
            "doubleData": null,
            "description": null,
            "value": "test1"
        }
    ]
}

 

0 Upvotes
Roja
Member

How do add new data in option select property use to api?

SOLVE

Hi, I am  trying update the dropdown list of the custom object property

 

I used below endpoint URL and body, Please correct me where I am going wrong

 

https://api.hubapi.com/crm/v3/properties/objectid/named/dropdown_name?hapikey=key

 

{
"name": "test",
"label": "test",
"groupName": "engineers_information",
"type": "enumeration",
"fieldType": "select",
"options": [
{
"label": "test",
"displayOrder":1,
"hidden": false,
"readOnly": false,
"doubleData": null,
"description": null,
"value": "test1"
}
]
}

 

 

I am receiving error:

404Not Found

The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.
0 Upvotes
Mike_Eastwood
Recognized Expert | Gold Partner
Recognized Expert | Gold Partner

How do add new data in option select property use to api?

SOLVE

Thank you @byersoy 

Super helpful.

–Mike

JasminLin
HubSpot Employee
HubSpot Employee

How do add new data in option select property use to api?

SOLVE

No problem @byersoy . To update a enumeration property, which is a property with options, you need to include in your request payload all of your existing options + the new option you want to add. If you only include the new option in your request payload, it will overwrite all of your existing options with only that new option you sent. 

0 Upvotes
DiogoMC
Participant | Platinum Partner
Participant | Platinum Partner

How do add new data in option select property use to api?

SOLVE

Hi;

Do you know if we include all the options + the new option in the payload, do the existing options remain the same (keeps contact values for the previously filled property)? For example, if contact "A" in the "car" property had the value "volvo" checked, and I add "Opel" to the "car options" through the API and include "volvo" in the payload, will the value on contact "A" be affected?

0 Upvotes
Mike_Eastwood
Solution
Recognized Expert | Gold Partner
Recognized Expert | Gold Partner

How do add new data in option select property use to api?

SOLVE

Hi @DiogoMC 

 

You prepend the value with a semi-colon to add a values, keeping the original value.

 

Assuming you have a multiselect checkbox with the options available:

  • Marketing Hub <marketing_hub>
  • Sales Hub <sales_hub>
  • Service Hub <service_hub>
  • CMS Hub <cms_hub>

For this example asssume Marketing Hub is already Selected

 

This adds to the current selection because the semicolon at the start so the field now has Marketing Hub, Sales Hub and Service Hub.

 

;sales_hub;service_hub

 

 

This clears Marketing Hub (because there's no semicolon at the start) and sets Sales Hub and Service Hub.

 

sales_hub;service_hub

 

You can NOT set Ops Hub <ops_hub> because the value isn't available in the Property (the API will throw an error).

 

Did that answer your question?

Mike

 

DiogoMC
Participant | Platinum Partner
Participant | Platinum Partner

How do add new data in option select property use to api?

SOLVE

Sorry Mike. I never replied. Yes, it Does. Thanks a million