I’ve checked the other posts on this issue and can’t find where I am going wrong in there.
My form submissions are returning 405 errors. I’m not sure why.
The confusing thing is that while I (and others) are getting the 405 error. It seems others aren’t as when I check the form submission on Hubspot I’m still getting submissions coming through,
Here’s how I’m preparing the data:
const postData = {
context: {
hutk: Cookies.get('hubspotutk'),
pageName: pageTitle,
pageUri: window.location.href,
},
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 communications from Company.',
},
],
},
},
fields: [],
};
postData.fields = fieldData.map(field => {
return { name: field.name, value: field.value };
});
const headers = {
Accept: 'application/json',
'Content-Type': 'application/json',
'Content-Length': (Object.keys(postData).length).toString(),
};
fetch(hubspotAPIEndpoint, {
method: 'POST',
headers,
body: JSON.stringify(postData),
mode: 'cors',
});
And here’s the data:
{
body: "{"context":{"pageName":"Mission Beyond","pageUri":"http://localhost:8000/"},"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 communications from Company."}]}},"fields":[{"name":"firstname","value":"test"},{"name":"lastname","value":"test"},{"name":"email","value":"test@example.com"}]}",
headers: {
Accept: "application/json",
Content-Length: "3",
Content-Type: "application/json", },
method: "POST",
mode: "cors",}
Let me know if I can clarify anything further, thanks for any help.