# reCaptcha integration problem using React/Gatsby

**URL:** <https://community.hubspot.com/t/recaptcha-integration-problem-using-react-gatsby/44385>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [September 27, 2021, 7:19am UTC](https://community.hubspot.com/t/recaptcha-integration-problem-using-react-gatsby/44385 "2021-09-27T07:19:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NicoElvino](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/nicoelvino/32/78108_2.png) [@NicoElvino](https://community.hubspot.com/u/NicoElvino)\
**Post date:** [September 27, 2021, 7:19am UTC](https://community.hubspot.com/t/recaptcha-integration-problem-using-react-gatsby/44385/1 "2021-09-27T07:19:28Z")

</div>

Hi guys, how are you?

I created my HubSpot form, and due to having the “follow up” option on, the ReCaptcha is mandatory. When I go to my front end (I’m using React and Gatsby) and I install reCaptcha and register my site, everything loads but the form doesn’t submit. It always gives me a POST error (400). It almost seems that the ReCaptcha that the HubSpot form autogenerates and the one my page generates are not the same one, like if there are some issues with the integration because it simply doesn’t work 😞  
Does anyone have any idea of what I’m doing wrong, or how to make it work?  
(just in case, if I go to my HubSpot form, delete the “follow up” and mandatory ReCaptcha, the form submits and works perfectly, but when I turn “follow up” again (and the mandatory ReCaptcha), it breaks. This leads me to think that the problem comes because the form is not recognizing the ReCaptcha value generated on my site.  
Thanks for your time!  
Nico

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [September 27, 2021, 6:22pm UTC](https://community.hubspot.com/t/recaptcha-integration-problem-using-react-gatsby/44385/2 "2021-09-27T18:22:21Z")

</div>

@miljkovicmisa , I feel like you might have some thoughts here 😺

---

<div class="post-metadata">

**Author:** ![miljkovicmisa](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/miljkovicmisa/32/86357_2.png) [@miljkovicmisa](https://community.hubspot.com/u/miljkovicmisa)\
**Post date:** [September 27, 2021, 7:20pm UTC](https://community.hubspot.com/t/recaptcha-integration-problem-using-react-gatsby/44385/3 "2021-09-27T19:20:12Z")

</div>

Hello @NicoElvino , 👋@dennisedson ,  
thank you for writing, could you elaborate a bit more on why you need that second captcha on you site? As far as I’m concerned hubspot forms bring the captcha with them out of the box, so you don’t actually need to “install” it again on your site, maybe I’m missing something here, also some kind of log would be helpful, maybe the console log you get?  
Cheers!

---

<div class="post-metadata">

**Author:** ![NicoElvino](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/nicoelvino/32/78108_2.png) [@NicoElvino](https://community.hubspot.com/u/NicoElvino)\
**Post date:** [September 27, 2021, 11:29pm UTC](https://community.hubspot.com/t/recaptcha-integration-problem-using-react-gatsby/44385/4 "2021-09-27T23:29:33Z")

</div>

Hi @miljkovicmisa, thanks for your reply!

No worries, I will try to explain better 🙂

**1** - I dont intend to use the “out of the box” HubSpot forms, but create custom ones and integrate them.

**2** - I built a website on React and Gatsby, deployed to gatsby cloud. In order to use Hubspot forms in there, Im creating my own forms and integrating HubSpot to them. I created 4 forms, all of them work perfectly, they submit, they send data and they dont have any issues.

For that, I use a code like this in my coponents, where I add my portal and form ID supplied from HutSpot:

const handleSubmit = (evt) =\> {

```
    evt.preventDefault();

    var xhr = new XMLHttpRequest();

    var url = 'https://api.hsforms.com/submissions/v3/integration/submit/5692042/f1905f2b-0c39-4a1f-8c96- 09c23514e92e'

    var data = {

        "fields": \[

            {

                "name": "firstname",

                "value": firstname

            },

            {

                "name": "email",

                "value": email

            }

        ],

```

Until here, everything works perfectly.

**ISSUE:**

**3** - When I go back to one of my working forms (is the same if I create a new one) and turn the “reCaptcha” on, then my forms spot working. (note: I dont even want to turn it on, but if I select the option “follow up”, then its mandatory to have it).

**First thing:** The automatic reCaptcha that is usually autogenerated in the “out of the box HubSpot form”, is not created in my custom component.

**Second:** if I add my own reCaptcha, now it displays and “works” (I mean, allows the user to interact and confirm that they are huamns), but the form doesnt submit, exactly the same as happened in the previous step. This takes me think that the problem is that the submit button is not storing the reCaptcha value, or expecting the one that should be “autogenerated” in the “out of the box form”, but that ll never happen as Im using my own forms.

**Error** :

POST [https://api.hsforms.com/submissions/v3/integration/submit/5692042/f1905f2b-0c39-4a1f-8c96-09c23514e92e](https://api.hsforms.com/submissions/v3/integration/submit/5692042/f1905f2b-0c39-4a1f-8c96-09c23514e92e) (400)

Probably its a simple solution, and hopefully Im simply missing something really basic that Im still now aware off!

Thanks for yout time!

Nico

---

<div class="post-metadata">

**Author:** ![miljkovicmisa](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/miljkovicmisa/32/86357_2.png) [@miljkovicmisa](https://community.hubspot.com/u/miljkovicmisa)\
**Post date:** [September 28, 2021, 7:36am UTC](https://community.hubspot.com/t/recaptcha-integration-problem-using-react-gatsby/44385/5 "2021-09-28T07:36:51Z")

</div>

Owww, okay, that explains it now, I thought that you are only doing the integration but you are also sending form data via API, that unfortunately is not possible, using captcha and sending form data programatically is not allowed. If you do a dump of the `errors` object you will see an entry that contains the `FORM_HAS_RECAPTCHA_ENABLED` errorType. Unfortunately there is no workaround except by using the hubspot embed code.  
You may have missed it when reading the docs, but [it is in this link waaaay down in the “errors” section](https://legacydocs.hubspot.com/docs/methods/forms/submit_form) of the table.  
_ **If my answer was helpful please mark it as a solution.** _
