How to insert enumeration field values into forms API?


#1

Hi,
I'm using PHP to POST form data to HubSpot Forms API. Everything works fine - submitted form data is stored in HubSpot correctly except enumeration fields.

I'm sending form data from my front-end APP to my backend APP and receives all data as an array in following structure:

[
  'firstname' => ...,
  'lastname' => ...,
  'email' => ...,
  'some_enumeration_field' => [
    'Value 1',
    'Value 2',
    ...
  ]
]

Than I'm using PHP CURL to send this data further into HubSpot API. I'm using code almost exact the same as shown in API examples. Only difference is that I'm using http_build_query function to parse array. But there is problem with enumaration fields, which are sub-arrays. In my submission details enumeration field values has exclamation icons next to them. And the key names are bad, they are stored this way:

some_enumeration_field_0_ : 'Value 1'
some_enumeration_field_1_ : 'Value 2'

Hovering the exclamation icon gives me following error:
"This value wasn't passed to the contact record. 'some_enumeration_field_0_' isn't a contact property."

So how to send enumeration data to HubSpot API properly that it will be recognised as an array of values?


#3

HI @Peronczyk, that error message seems to indicate that the enumeration property that you're trying to send data to in HubSpot does not exist. The field that stores the data in HubSpot has to exist on the contact in your property settings: https://app.hubspot.com/property-settings/HUBID/contact.

Can you check that the field exists in HubSpot that you're trying to pass data to? If that doesn't work, can you send me a bit more information?

  1. The request body that you're sending back to HubSpot.
  2. A link to the form in HubSpot that you're sending data to.

Thank you


#4

Field some_enumeration_field in my example exists in HubSpot.

Ad 1. Here is example body of data that is send to HubSpot with PHP curl_exec() function:

firstname=Somebody&lastname=Somename&jobtitle=Dev&email=somebody%40somecompany.com&company=Somecompany&nearshoring_it_challenge%5B0%5D=My+company+lacks+enough+IT+expertise&nearshoring_it_challenge%5B1%5D=No+IT+challenges+at+all&i_agree_to_the_processing_of_my_personal_data_by_future_processing_sp_z_o_o_for_marketing_purposes_=Yes&i_would_like_to_receive_commercial_and_marketing_information=Yes&n1receiving_commercial_communications_and_marketing_information_of_future_processing_by_use_of_tele=Yes&hs_context=%7B%22hutk%22%3A%<REMOVED>%22%2C%22pageUrl%22%3A%22%5C%2Fknowledge%5C%2Fhow-to-write-an-rfi-for-outsourced-it-projects%22%2C%22pageName%22%3A%22Download+Free+RFI+template+for+software+development+%7C+Start+Nearshoring%22%2C%22ipAddress%22%3A%22<REMOVED>%22%7D

In this real life example field nearshoring_it_challenge is enumeration.

Ad 2. Here is link to one of the forms that has problem with enumeration fields: https://startnearshoring.com/knowledge/how-to-write-an-rfi-for-outsourced-it-projects
Hubspot: https://app.hubspot.com/forms/421670/fb8bf81a-b32e-4647-94bb-baf7a89d98ef


#5

Hi @Peronczyk, looks like this is a quirk with HubSpot the values in an enumeration field should be separated by a semicolon. I was able to get a form submission to work by using this request body:

firstname=Connor&lastname=B&jobtitle=Dev&email=cbarley@hubspot.com&nearshoring_it_challenge=My+company+lacks+enough+IT+expertise;No+IT+challenges+at+all

Here's my contact in your portal: https://app.hubspot.com/contacts/421670/contact/7186248/?interaction=note

And here's a thread that talks about this a bit more:


#6

Thank you for your response - you've helped me a lot. To be honest this is something even more than "quirk" :slight_smile: