<p>In a separate thread, it was determined that in this situation React was being used and the data being posted to Sprout Forms was null. The general takeaway was to ensure the correct data was being posted to Sprout Forms.</p>

<p>One crude way to try to see what Sprout Forms is seeing when you submit a post request is to add a die statement to the <code>vendor/barrelstrength/sprout-forms/src/controllers/EntriesController.php</code> actionSaveEntry method.</p>

<pre><code>Craft::dd($_POST);
</code></pre>

<p>Also, make sure you are passing the Sprout Forms action as a parameter in the URL:</p>

<pre><code>http://website.com?action=sprout-forms/entries/save-entry
</code></pre>

<p>In this case, the data for the React application needed to be passed to the endpoint using the <code>querystring.stringify</code> as <code>JSON.stringify</code> did not suffice:</p>

<pre><code>axios.post(url, querystring.stringify(data))
</code></pre>

CC BY-SA 4.0
2018-10-08T06:19:56.050Z
Thanks very much Ben and @andre-l for your assistance to have this resolved - greatly appreciated.
Lance
CC BY-SA 4.0
2018-10-04T14:17:26.477Z
2018-10-23T15:02:57.363Z
2018-10-23T15:02:57.363Z
Ben Parizek
<p>If you're using template overrides, could you please make sure that the next line is in the <code>&lt;form&gt; ... &lt;\form&gt;</code> tag?</p>

<p><code>{% hook 'sproutForms.modifyForm' %}</code></p>

<p>This line is required in Sprout Forms for Craft3 if you have the spam protection enabled in the plugin settings.</p>

CC BY-SA 4.0
2018-09-24T22:18:56.193Z
2018-09-24T22:18:56.193Z
Andre L.
<p>I am able to capture submissions from a regular HTML form, however if I replicate the POST with JSON I get the following "Template not found" error.</p>

<pre><code>Template not found: sprout-forms/entries/save-entry
1. in /var/www/Applications/vendor/craftcms/cms/src/controllers/TemplatesController.php
at line 70 61626364656667686970717273747576777879
  * @param string $template
  * @param array $variables
  * @return Response
  * @throws NotFoundHttpException if the requested template cannot be found
  */
 public function actionRender(string $template, array $variables = []): Response
 {
     // Does that template exist?
     if (!$this-&gt;getView()-&gt;doesTemplateExist($template)) {
         throw new NotFoundHttpException('Template not found: ' . $template);
     }

     // Merge any additional route params
     $routeParams = Craft::$app-&gt;getUrlManager()-&gt;getRouteParams();
     unset($routeParams['template'], $routeParams['template']);
     $variables = array_merge($variables, $routeParams);

     return $this-&gt;renderTemplate($template, $variables);
 }

2. craft\controllers\TemplatesController::actionRender('sprout-forms/entries/save-entry', [])

....

11. in /var/www/Applications/web/index.php at line 21 – yii\base\Application::run() 15161718192021
                     (new Dotenv\Dotenv(CRAFT_BASE_PATH))-&gt;load(); }   // Load and run Craft define('CRAFT_ENVIRONMENT',
getenv('ENVIRONMENT') ?: 'production'); $app = require
CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php'; $app-&gt;run();
</code></pre>

<p>I have disabled CSRF for now in the hope of taking that out of the equation.</p>

<p>I believe I have replicated the HTML form request with a JSON POST using Postman but am hitting a dead-end. Any assistance with debug steps, or a sample Postman config to a working solution would be hugely appreciated.</p>

<plugins><ajax><plugin-sproutforms>
Sprout forms AJAX submission giving Template not found
# Sprout forms AJAX submission giving Template not found

(Asked by: username_0 on 2018-09-20)

I am able to capture submissions from a regular HTML form, however if I replicate the POST with JSON I get the following "Template not found" error.
Template not found: sprout-forms/entries/save-entry
1. in /var/www/Applications/vendor/craftcms/cms/src/controllers/TemplatesController.php
at line 70 61626364656667686970717273747576777879
  * @param string $template
  * @param array $variables
  * @return Response
  * @throws NotFoundHttpException if the requested template cannot be found
  */
 public function actionRender(string $template, array $variables = []): Response
 {
     // Does that template exist?
     if (!$this->getView()->doesTemplateExist($template)) {
         throw new NotFoundHttpException('Template not found: ' . $template);
     }

     // Merge any additional route params
     $routeParams = Craft::$app->getUrlManager()->getRouteParams();
     unset($routeParams['template'], $routeParams['template']);
     $variables = array_merge($variables, $routeParams);

     return $this->renderTemplate($template, $variables);
 }

2. craft\controllers\TemplatesController::actionRender('sprout-forms/entries/save-entry', [])

....

11. in /var/www/Applications/web/index.php at line 21 – yii\base\Application::run() 15161718192021
                     (new Dotenv\Dotenv(CRAFT_BASE_PATH))->load(); }   // Load and run Craft define('CRAFT_ENVIRONMENT',
getenv('ENVIRONMENT') ?: 'production'); $app = require
CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php'; $app->run();

I have disabled CSRF for now in the hope of taking that out of the equation.
I believe I have replicated the HTML form request with a JSON POST using Postman but am hitting a dead-end. Any assistance with debug steps, or a sample Postman config to a working solution would be hugely appreciated.

**Tags:** plugins, ajax, plugin-sproutforms


---

## 2 answers

### Answer by username_1 on 2018-10-04. Score: 0 | Accepted answer

In a separate thread, it was determined that in this situation React was being used and the data being posted to Sprout Forms was null. The general takeaway was to ensure the correct data was being posted to Sprout Forms.
One crude way to try to see what Sprout Forms is seeing when you submit a post request is to add a die statement to the vendor/barrelstrength/sprout-forms/src/controllers/EntriesController.php actionSaveEntry method.
Craft::dd($_POST);

Also, make sure you are passing the Sprout Forms action as a parameter in the URL:
http://website.com?action=sprout-forms/entries/save-entry

In this case, the data for the React application needed to be passed to the endpoint using the querystring.stringify as JSON.stringify did not suffice:
axios.post(url, querystring.stringify(data))

> **Comments:**
> **username_0**: Thanks very much Ben and @andre-l for your assistance to have this resolved - greatly appreciated.  

---

### Answer by username_2 on 2018-09-24. Score: 0

If you're using template overrides, could you please make sure that the next line is in the  `... <\form>` tag?

`{% hook 'sproutForms.modifyForm' %}`

This line is required in Sprout Forms for Craft3 if you have the spam protection enabled in the plugin settings.


---

