I’m trying to push form data to Hubspot using the API (https://developers.hubspot.com/docs/methods/forms/submit_form_v3) but I’m getting a 405 error.
Problem accessing /submissions/v3/integration/submit/[portalID]/[formGUID]
Reason: Method Not Allowed
// The following is inside a click event on a button var data = {
"fields": output,
"context": {
"hutk": hubCookie,
"pageUri": pageURL,
"pageName": pageName
},
"legalConsentOptions": {
"consent": {
"consentToProcess": true,
"text": "I agree to allow Company to store and process my personal data.",
// "communications": [
// {
// "value": true,
// "subscriptionTypeId": 999,
// "text": "I agree to receive marketing communications from Example Company."
// }
// ]
}
},
'skipValidation': true,
}
if ($(this).is('.step1')) {
$.ajax({
url: 'https://api.hsforms.com/submissions/v3/integration/submit/[portalID]/[formGUID]',
type: "POST",
contentType: "application/json",
dataType: "json",
headers: {
"accept": "application/json",
"Access-Control-Allow-Origin":"*"
},
type: "POST",
data: data,
success: function (result) {
console.log(result);
},
error: function (status, error) {
console.log(error, status);
}
});
}
I appreciate any help ![]()
Edit:
I’m getting this error:
“Invalid input JSON on line 1, column 8: Unrecognized token ‘fields’: was expecting ‘null’, ‘true’, ‘false’ or NaN” which seems like it might be to do with stringify-ing the JSON first, but my JSON is.
What I get when I console log the output of the “output” variable I’m using for the fields
[{“name”:“firstname”,“value”:“as”},{“name”:“lastname”,“value”:“as”},{“name":“email”,“value”:"as@a.com”}]