APIs & Integrations

RYu7
Member

Form data submit 400 error

Hi there,

 

I am trying to submit a form data using "Submit data form" API:

 
Here is the data I submit: 
{"submittedAt":"1654763483000","fields":[{"objectTypeId":"0-1","name":"firstName","value":"Robert"},{"objectTypeId":"0-1","name":"lastName","value":"Yu"},{"objectTypeId":"0-1","name":"email","value":"robert+88@interactivelabs.co"},{"objectTypeId":"0-1","name":"jobTitle","value":"test title"},{"objectTypeId":"0-2","name":"name","value":"test company name"}]}
 
Here is the error I got:
"errors": [
{
"message": "Error in 'fields.0-2/name'. Field '0-2/name' isn't in form definition",
"errorType": "FIELD_NOT_IN_FORM_DEFINITION"
}
]
 
From my understanding that "objectTypeId":"0-2" means Company object and this object should have the field "name", right?
0 Upvotes
3 Replies 3
advance512
Contributor

Form data submit 400 error

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
Jaycee_Lewis
Community Manager
Community Manager

Form data submit 400 error

Hey, @RYu7 👋 Thanks for reaching out. It is hard to know for sure without seeing the form. The error you are getting is related to changes outlined here related to how we validate forms — Upcoming Validation Change to the Forms API Submission Endpoints

 

Section two of that article has more insight into the error you are receiving. “Developers will see a...FIELD_NOT_IN_FORM_DEFINITION error message with a 400 status code in API responses for forms that do not meet the new submission validation.

 

Moving forward, I'd suggest:

  • linking your form here, so the community can take a look
  • if you or your client have access to support, it may be worth filing a support ticket, but they will request a link to an example as well

Thank you!  — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
RYu7
Member

Form data submit 400 error

0 Upvotes