APIs & Integrations

egami
Participant

Contact isn't created when form is submitted with Hubspot user token set

As the title says, contact isn't created when form is submitted with Hubspot user token set.

 

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

 

I confirmed I got HubSpot user token which is stored in browser as "hubspotutk" and submitted form with it.

When I submitted form without the token, contact was successfully created.

 

My code is as follows:

 

 

 

const options = {
  method: 'post',
  headers: {
    'Content-Type': 'application/json',
  },
  withCredentials: true,
};

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: [
      {
        objectTypeId: '0-1',
        name: 'lastname',
        value: 'test1',
      },
      { 
        objectTypeId: '0-1',
        name: 'firstname',
        value: 'test2',
      },
      {
        objectTypeId: '0-1',
        name: 'email',
        value: 'test@example.com',
      },
      {
        objectTypeId: '0-1',
        name: 'phone',
        value: 0801234567,
      },
      {
        objectTypeId: '0-2',
        name: 'name',
        value: 'test,Inc',
      },
    ],
    context: {
      hutk: 'xxxxxxxx',
      pageUri: 'http://localhost:5500/test',
      pageName: 'test page',
    },
  },
  options,
);

 

 

 

 

Hope someone tells me to work it out.

 

0 Upvotes
1 Reply 1
Jaycee_Lewis
Community Manager
Community Manager

Contact isn't created when form is submitted with Hubspot user token set

Hi @egami Thanks for reaching out. Did you get this worked out? If not, we can invite some community members to see if they have any relevant experience.

 

Thank you! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes