APIs & Integrations

RSaunders7
Member

Form Submission returns 200 but no submissions showing

Hello,

 

I'm currently trying to integrate a form.

 

I have created the custom form and set up the below code, sending the raw JSON via postman returns 200 with an empty object and nothing more, no submissions are showing in hubspot.

 

Below is the code (TypeScript) with some details replaced with placeholders (keys etc). Any help would be appreciated.

 

const res = await fetch(
    `https://api.hsforms.com/submissions/v3/integration/secure/submit/${portalId}/${formGuid}`,
    {
      method: "POST",
      headers: {
        authorization: `${HUBSPOT_API_PAT}`,
        "Content-Type": "application/json",
      },
      body: {
        timestamp: currentDate.getTime(),
        fields: [
          {
            objectTypeId: "0-1",
            name: "firstname",
            value: "John",
          },
          {
            objectTypeId: "0-1",
            name: "lastname",
            value: "Doe",
          },
          {
            objectTypeId: "0-1",
            name: "email",
            value: "example@test.com",
          },
          {
            objectTypeId: "0-1",
            name: "zip",
            value: "QW11ER,
          },
          {
            objectTypeId: "0-1",
            name: "taster_session",
            value: "session picked",
          },
        ],
        legalConsentOptions: {
          consent: {
            // Include this object when GDPR options are enabled
            consentToProcess: true,
            text: "I agree to allow Example Company to store and process my personal data.",
            communications: [
              {
                value: true,
                subscriptionTypeId: 999,
                text: "I agree to receive marketing communications from Example Company.",
              },
            ],
          },
        },
      },
    }

 

 

0 Upvotes
3 Replies 3
Jaycee_Lewis
Community Manager
Community Manager

Form Submission returns 200 but no submissions showing

Hi, @RSaunders7 👋 Welcome to our community! I hope you got this resolved. 

 

If not, have you tried stringifying the JSON payload in the body of your fetch request? Also, you may need to adjust your timestamp field to be 
submittedAt: currentDate.getTime()

 

Have fun testing! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
RSaunders7
Member

Form Submission returns 200 but no submissions showing

Having made those changes we are now getting a 400 response instead of a 200.

0 Upvotes
RSaunders7
Member

Form Submission returns 200 but no submissions showing

Sadly those solutions didn't work out, I appreciate the warm welcome and response though!

0 Upvotes