APIs & Integrations

calicoderco
Member

API field names don't correspond to Form UI field names

I'm using the form API to submit from my javascript client to my forms in hubspot. Some of the fields are ok: I am able to tell what name they should be from the name in the form UI. But most of them, and especially any non standard one such as "date of birth", don't work. I tried data_of_birth, dateofBirth, dateOfBirth, DateOfBirth, date_of_birth_property...nothing works. Worse yet, the API docs do not cover this. It only says "it follows the same format as the Contacts API". But when you look at the Contacts API, it doesn't use the fields: {} field it uses properties: {}. And still doesn't dicuss the format. This is a crucial piece of info to use the API. https://developers.hubspot.com/docs/methods/forms/submit_form_v3

No matter what I put in the request, I always get something like:

{
"status": "error",
"message": "The request is not valid",
"correlationId": "6df6de0c-ee28-4934-b585-208650f06619",
"errors": [
{
"message": "Error in 'fields.dateofbirth'. Field 'dateofbirth' isn't in form definition",
"errorType": "FIELD_NOT_IN_FORM_DEFINITION"
}
],
"requestId": "858912a1da6908f18b68e0e5c8f5cd8a"
}

Request payload:

{
"fields": [
{"name": "email", "value": "brucewayne@gmail.com"},
{"name": "firstname", "value": "Bruce"},
{"name": "lastname", "value": "Wayne"},
{"name": "phone", "value": "4052023432"},
{"name": "date_of_birth", "value": "04231956"}

],
"legalConsentOptions": {
"legitimateInterest": {
"value": true,
"subscriptionTypeId": 999,
"legalBasis": "CUSTOMER",
"text": "Legitimate interest consent text"
}
}
}

0 Upvotes
4 Replies 4
advance512
Contributor

API field names don't correspond to Form UI field names

We had the same issue.

 

The issue is that Forms behavior changed a few months ago:
https://developers.hubspot.com/changelog/validation-change-to-the-forms-api-submission-endpoints


Before, forms didn't require to add Fields (=properties) to them. If the fields were valid, the forms worked. We had a form with no Fields in it, except for the email, so we had complete flexibility in the dev side. It worked.
After the change, for forms created from March 22 and onwards, you need to include all relevant fields explicitly in the form. 

 

Forms older than March 22 should still work with the previous behavior, this is what Hubspot say.

But for some reason, it won't work with newer fields created after March 22, even if the form is older.
It's like what they said about the granularity is wrong - it's about the date of the fields that are used in the form, not the the date of the form itself.

 

We added the Field to the old Form (marked it as not required) and it worked. All older Fields that were submitted via the Form without being added, still work. Weird.

0 Upvotes
alannab
Participant

API field names don't correspond to Form UI field names

Hey calicoderco, we are experiencing the same issue. Did you ever find a resolution for this? 

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

API field names don't correspond to Form UI field names

@alannab 

Might be worth adding your payload here.  Also make sure to look at  @hot_z  tip 😀

0 Upvotes
hot_z
Contributor

API field names don't correspond to Form UI field names

Hi,

Going from the error message, it seems like the wrong internal name for the field might have been used here. A great way to check into this is to head over to your property settings in HS, find this property and check the 'Internal name'. I hope that helps!