# Hubspot form API 405 error

**URL:** <https://community.hubspot.com/t/hubspot-form-api-405-error/18302>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [January 23, 2020, 5:40pm UTC](https://community.hubspot.com/t/hubspot-form-api-405-error/18302 "2020-01-23T17:40:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [January 23, 2020, 5:40pm UTC](https://community.hubspot.com/t/hubspot-form-api-405-error/18302/1 "2020-01-23T17:40:28Z")

</div>

I’m trying to push form data to Hubspot using the API ([https://developers.hubspot.com/docs/methods/forms/submit\_form\_v3](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

```auto
// 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](mailto:name%22:%22email%22,%22value%22:%22as@a.com)”}]

---

<div class="post-metadata">

**Author:** ![WendyGoh](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wendygoh/32/42320_2.png) [@WendyGoh](https://community.hubspot.com/u/WendyGoh)\
**Post date:** [January 24, 2020, 6:35am UTC](https://community.hubspot.com/t/hubspot-form-api-405-error/18302/2 "2020-01-24T06:35:55Z")

</div>

Hey @piersg,

Looking at your code, nothing major really stood out and I think your hypothesis may be right. In this case, could you try JSON stringify the data by replacing the following code:

```auto
data: data,

```

to

`data: JSON.stringify(data),`

and see if this works?

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [January 24, 2020, 9:43am UTC](https://community.hubspot.com/t/hubspot-form-api-405-error/18302/3 "2020-01-24T09:43:47Z")

</div>

Hey @WendyGoh

With that addition I’m now getting

“Invalid input JSON on line 1, column 11: Cannot deserialize instance of `java.util.ArrayList` out of VALUE\_STRING token”

**Edit**

I’ve got valid JSON now! Just getting “The request is not valid” error message

**Edit** 2

The invalid request was because CAPTCHA was enabled on the form

---

<div class="post-metadata">

**Author:** ![WendyGoh](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wendygoh/32/42320_2.png) [@WendyGoh](https://community.hubspot.com/u/WendyGoh)\
**Post date:** [January 29, 2020, 1:12am UTC](https://community.hubspot.com/t/hubspot-form-api-405-error/18302/4 "2020-01-29T01:12:42Z")

</div>

Hey @piersg,

Awesome! Glad to know all’s well here!

Thanks for sharing your findings 🙂

---

<div class="post-metadata">

**Author:** ![Nagarjoon](https://avatars.discourse-cdn.com/v4/letter/n/e5b9ba/32.png) [@Nagarjoon](https://community.hubspot.com/u/Nagarjoon)\
**Post date:** [April 23, 2024, 1:19pm UTC](https://community.hubspot.com/t/hubspot-form-api-405-error/18302/5 "2024-04-23T13:19:07Z")

</div>

It sounds like you’re encountering a “Method Not Allowed” error (405) when trying to push form data to HubSpot’s API. This error typically occurs when the HTTP method used in your request is not supported by the endpoint you’re trying to access. In this case, it seems like you might be using an incorrect HTTP method. The documentation you provided specifies that you should use the POST method to submit form data to HubSpot’s API. Double-check your code or request to ensure that you’re indeed using the POST method. Additionally, ensure that you’re using the correct endpoint URL, including your portal ID and form GUID placeholders. If the issue persists, review your API credentials and permissions to ensure they have the necessary access to submit form data. Finally, consider reaching out to HubSpot’s support or consulting their documentation for further assistance or troubleshooting tips tailored to your specific situation.
