Form submission error when form contains company property

I submitted form data to a HubSpot form using this endpoint.

However, error occurred when the form contains company property.

My form fields are as follows:

・lastname

・firstname

・email

・phone

・name (Company property)

Only “name” which is company name, is company property and the rest are all contact property.

Code is as follows:

const options = {
 headers: {
 'Message-Type': 'application/json',
 },
};

const portalId = 'xxxxx';
const formGuid = 'xxxxx';
const url = `https://api.hsforms.com/submissions/v3/integration/submit/${portalId}/${formGuid}`;

await axios.post(
 url,
 {
 portalId,
 formGuid,
 fields: [
 {
 name: 'lastname',
 value: 'test1',
 },
 {
 name: 'firstname',
 value: 'test2',
 },
 {
 name: 'email',
 value: 'test@example.com',
 },
 {
 name: 'phone',
 value: 0801234567,
 },
 {
 name: 'name',
 value: 'test,Inc',
 },
 ],
 },
 options,
);

Do I need to do something with “name” property?

Hope someone tells me the way to work it out.

Hi, @egami :waving_hand: Thanks for your question. One difference in your JSON body example from what the documentation shows is the use of

"objectTypeId"

Can you try setting the objectTypeID for each of your fields? For Contact properties it’s 0-1 and for Company properties it’s 0-2.

Here’s an example:

"fields": [
 {
		 "objectTypeId": "0-1",
 "name": "email",
 "value": "example@example.com"
 },
 {
		 "objectTypeId": "0-2",
 "name": "name",
 "value": "HubSpot"
 }
 ]

Here’s a link to the objectIds for our default Objects, Contacts, Companies, Deals, etc.

Have fun building! — Jaycee

Thank you for the reply @Jaycee_Lewis.

Everything worked when I set objectTypeId as you suggested!