APIs & Integrations

znwhite
Member

form submit API v3 not responding to POST request

SOLVE

I'm in a React/Next.js project and trying to test the v3 form submit API endpoint.

 

I'm using the axios package to send the POST request, here is my code:

 

 

 

import axios from 'axios';

export const submit_hs_form = async () => {
  const portalId = 'my_portal_id';
  const formGuid = 'my_form_guid';
  const res = await axios.post(
    `https://api.hsforms.com/submissions/v3/integration/submit/${portalId}/${formGuid}`,
    {
      portalId,
      formGuid,
      fields: [
        {
          name: 'email',
          value: 'sdfsfd33@gmail.com',
        },
      ],
    }
  );
  return res;
};

 

 

Every time I call the function, I get no response. The request hangs for over 10 seconds and then nothing happens, and I don't see anything new submissions in my forms dashboard in HubSpot.

 

Anybody have any idea why this might be happening?

 

This is just a regular function I am calling from my frontend.

0 Upvotes
1 Accepted solution
znwhite
Solution
Member

form submit API v3 not responding to POST request

SOLVE

Thanks @dennisedson. I added "Content-Type": "application/json" to the header of the request and it appears to work.

For anyone interested, I actually ended up writing a blog post showing you how to do it: https://www.devtwins.com/blog/hubspot-forms-react-submit-form-using-hubspot-api

 

Thanks again.

View solution in original post

3 Replies 3
znwhite
Solution
Member

form submit API v3 not responding to POST request

SOLVE

Thanks @dennisedson. I added "Content-Type": "application/json" to the header of the request and it appears to work.

For anyone interested, I actually ended up writing a blog post showing you how to do it: https://www.devtwins.com/blog/hubspot-forms-react-submit-form-using-hubspot-api

 

Thanks again.

dennisedson
HubSpot Product Team
HubSpot Product Team

form submit API v3 not responding to POST request

SOLVE
Amazing and so great that you added an example!
0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

form submit API v3 not responding to POST request

SOLVE

hi @znwhite 

Might need a bit more info to solve. 

Are you getting an error at all?

Are your headers set to submit json?

@tjoyce can probably help here 

0 Upvotes