204 Error: Submit User Data to Hubspot


Hi everyone!

We're trying to connect a custom sign-up form on our website to the Hubspot Forms API and running into some issues.

We're pushing page views to window._hsq on page transition via https://developers.hubspot.com/docs/methods/tracking_code_api/identify_visitor. Think this is working.

// init
var isInit = true;

// on $state transition
$transitions.onSuccess({}, function (transition) {
 // define hub spot object
 $window._hsq = $window._hsq || [];

 // send $state to hubspot
 $window._hsq.push([ 'setPath', transition.to().url ]);

 // if not init -> tell hubspot to track this page view
 // not required on init https://developers.hubspot.com/docs/methods/tracking_code_api/tracking_code_overview#spa
 if (!isInit) $window._hsq.push([ 'trackPageView' ]);

 // tip isInit
 isInit = false;

Then we're sending user data to Hubspot via https://developers.hubspot.com/docs/methods/forms/submit_form_v3.

// define data
var data = {
 "portalId": "1229789",
 "formGuid": "e651236b-4d20-453e-a0d6-76f7330e1238",
 "submittedAt": 1542718668884,
      "name": "firstname",
      "value": "a"
      "name": "lastname",
      "value": "b"
      "name": "email",
      "value": "a@c.com"
   "hutk": "5ed4d4eec89b95727d50742cb49507bb",
   "pageName": "un-auth-signup",
   "pageUri": "/signup?iframe&email"

return $http.post('https://api.hsforms.com/submissions/v3/integration/submit/4920989/f561b96b-4d20-453e-a0d6-76f7456e2438', data);

The response is erroring out for us in Angular:

  • status: -1
  • xhrStatus: "error"

Any idea what we need to do differently? Much appreciated!


Welcome, @abby.perkins!

Happy to help, but I have some questions:

  1. Is your website a single-page application?
  2. Account 1229789 is no longer active, so it won't be possible to submit to any forms with that Hub ID (portalId). did you mean to type a different value?
  3. At the end of your code block, I see the request URL https://api.hsforms.com/submissions/v3/integration/submit/4920989/f561b96b-4d20-453e-a0d6-76f7456e2438. There are no active forms in that account, so the formGuid f561b96b-4d20-453e-a0d6-76f7456e2438 won't work either.

Can you send me a link to the form in your account which you are attempting to submit to?



Appreciate you for the reply

Form => https://dev-app.glew.io/#/signup
Code =>


Hi @ccarrin2,

Thanks for confirming your Hub ID and sharing that data.

I successfully made this test submission from Postman using https://api.hsforms.com/submissions/v3/integration/submit/4929709/e651b96b-4d20-453e-a0d6-76f7330e2438, so there's nothing wrong with your request URL.

I'm noticing that the data object is not properly-formatted JSON. Unless you're converting it to JSON in the part of the "send user data" request" which is cut off in that screenshot, I don't think this request would work.

Per the Forms API documentation, the body should have double quotes around everything except variables. For example:

  "submittedAt": $window.Date.now(),
  "fields": [
      "name": "email",
      "value": self.form.email

The email object also has an extra , at the end even though it's the last object in the fields array, but I don't know that this alone would cause the issues you're seeing.

Let me know if adding proper JSON format to the data object helps!