Answers.Body: <p>You need to add <code>sectionId</code> to your form:</p>
  <pre><code>{{ hiddenInput('sectionId', xx) }}
  </code></pre>
  <p>If you have multiple entry types, you can also add <code>typeId</code> to the form:</p>
  <pre><code>{{ hiddenInput('typeId', xx) }}
  </code></pre>
  <p>For both examples, replace <code>xx</code> with an actual value, of course :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-01T12:04:35.360Z
Answers.Text: I did have that in initially but the craft example says to switch 'sectionId' for the id of the section you're posting to. So I changed it to 'blog' but got the error code. Am I supposed to leave  {{ hiddenInput('sectionId', '2') }} untouched and specify the blog somewhere else?
Answers.UserDisplayName: George Bleasdale
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-01T12:33:39.850Z
Answers.Text: You need to change `2` to your actual section id. You can find that by going to **Settings → Sections**, click your section then look at the number in your address bar. Alternatively, you'll find this in your database's `sections` table.
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-02T06:10:23.843Z
Answers.Text: That was what I was missing, thank you!!
Answers.UserDisplayName: George Bleasdale
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-01T10:59:30.050Z
Answers.LastActivityDate: 2022-12-01T10:59:30.050Z
Answers.UserDisplayName: Oli
Body: <p>I'm pretty new to craft and creating my first front end entry form using the demo code provided by craft. For some reason I'm getting a 'Request missing required body param' error. I've tried adding  but that didn't solve the issue.</p>
  <p>Here's my code:</p>
  <pre><code>{% extends &quot;_layout.twig&quot; %}
  
  {% macro errorList(errors) %}
    {% if errors %}
      {{ ul(errors, {class: 'errors'}) }}
    {% endif %}
  {% endmacro %}
  
  {# If there were any validation errors, an `entry` variable will be 
     passed to the template, which contains the posted values 
     and validation errors. If that’s not set, we’ll default 
     to a new entry. #}
  {% set entry = entry ?? create('craft\\elements\\Entry') %}
  
  {# Add `enctype=&quot;multipart/form-data&quot;` to `&lt;form&gt;` if you’re 
     uploading files. #}
  &lt;form method=&quot;post&quot; accept-charset=&quot;UTF-8&quot; enctype=&quot;multipart/form-data&quot;&gt;
    {{ csrfInput() }}
    {{ actionInput('entries/save-entry') }}
    {{ redirectInput('viewentry/{slug}') }}
    {{ hiddenInput('friends', '2') }}
  
  &lt;input type=&quot;hidden&quot; name=&quot;entryId&quot; value=&quot;&quot;&gt;
  
  &lt;div class=&quot;mb-6&quot;&gt;
    &lt;label for=&quot;title&quot; class=&quot;block mb-2 text-sm font-medium text-gray-900 dark:text-white&quot;&gt;Your Dog's Name&lt;/label&gt;
    {{ input('text', 'title', entry.title, {
      id: 'title',
      class:'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500',
    }) }}
    {{ _self.errorList(entry.getErrors('title')) }}
  &lt;/div&gt;
    
  &lt;div class=&quot;mb-6&quot;&gt;
  &lt;label for=&quot;featureImage&quot; class=&quot;block mb-2 text-sm font-medium text-gray-900 dark:text-white&quot;&gt;Feature Image&lt;/label&gt;
  
    {{ input('file', 'featureImage', entry.featureImage, {
      id: 'featureImage',
    }) }}
    {{ _self.errorList(entry.getErrors('featureImage')) }}
  &lt;/div&gt;
  
  &lt;div class=&quot;mb-6&quot;&gt;
    &lt;label for=&quot;postContent&quot; class=&quot;block mb-2 text-sm font-medium text-gray-900 dark:text-white&quot;&gt;Tell us about your dog&lt;/label&gt;
    {{ tag('textarea', {
      id: 'postContent',
      name: 'fields[postContent]',
      class:'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500',
    }) }}
    {{ _self.errorList(entry.getErrors('postContent')) }}
  &lt;/div&gt;
  
  
  &lt;div class=&quot;mb-8&quot;&gt;
  &lt;label for=&quot;postCategories&quot; class=&quot;block mb-2 text-sm font-medium text-gray-900 dark:text-white&quot;&gt;Breed&lt;/label&gt;
  &lt;select name=&quot;fields[postCategories]&quot; id=&quot;postCategories&quot;&gt;
      {# Create a category query with the 'group' parameter #}
  {% set myCategoryQuery = craft.categories()
    .group('blog') %}
  {# Fetch the categories #}
  {% set categories = myCategoryQuery.all() %}
    {# display post categories #}
    {% if entry.postCategories|length %}
    &lt;div class=&quot;border-t py-2 mb-6&quot;&gt;
      {% for category in entry.postCategories.all() %}
        &lt;a href=&quot;{{ category.url }}&quot; class=&quot;inline-block border rounded px-2 py-1 text-sm&quot;&gt;
          {{- category.title -}}
        &lt;/a&gt;
      {% endfor %}
    &lt;/div&gt;
    {% endif %}
    {% nav category in categories %}
      &lt;li&gt;
        &lt;option&gt;{{ category.title }}&lt;/option&gt;
      &lt;/li&gt;
    {% endnav %}  
  &lt;/select&gt;
  &lt;/div&gt;
  {#
  {% set field = craft.app.fields.getFieldByHandle('postCategories') %}
  
  {{ hiddenInput('fields[postCategories]', '') }}
  
  &lt;select multiple name=&quot;fields[postCategories][]&quot;&gt;
    {% for option in field.options %}
        {% set selected = entry is defined
          ? entry.postCategories.contains(option.value)
          : option.default %}
  
        &lt;option value=&quot;{{ option.value }}&quot;
          {% if selected %} selected{% endif %}
        &gt;
          {{ option.label }}
        &lt;/option&gt;
    {% endfor %}
  &lt;/select&gt;
  #}
  &lt;div class=&quot;mb-6&quot;&gt;
    &lt;button type=&quot;submit&quot; class=&quot;text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800&quot;&gt;Publish&lt;/button&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  
  {% endblock %}
  </code></pre>
  
Tags: <frontend-form><params><entry-form>
Title: 'Request missing required body param' when submitting front end entry form - Craft CMS
ThreadText: # 'Request missing required body param' when submitting front end entry form - Craft CMS
  
  (Asked by: username_0 on 2022-12-01)
  
  I'm pretty new to craft and creating my first front end entry form using the demo code provided by craft. For some reason I'm getting a 'Request missing required body param' error. I've tried adding but that didn't solve the issue.
  
  Here's my code:
  
  ```
  {% extends "_layout.twig" %}
  
  {% macro errorList(errors) %}
    {% if errors %}
      {{ ul(errors, {class: 'errors'}) }}
    {% endif %}
  {% endmacro %}
  
  {# If there were any validation errors, an `entry` variable will be 
     passed to the template, which contains the posted values 
     and validation errors. If that’s not set, we’ll default 
     to a new entry. #}
  {% set entry = entry ?? create('craft\\elements\\Entry') %}
  
  {# Add `enctype="multipart/form-data"` to `<form>` if you’re 
     uploading files. #}
  <form method="post" accept-charset="UTF-8" enctype="multipart/form-data">
    {{ csrfInput() }}
    {{ actionInput('entries/save-entry') }}
    {{ redirectInput('viewentry/{slug}') }}
    {{ hiddenInput('friends', '2') }}
  
  <input type="hidden" name="entryId" value="">
  
  <div class="mb-6">
    <label for="title" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your Dog's Name</label>
    {{ input('text', 'title', entry.title, {
      id: 'title',
      class:'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500',
    }) }}
    {{ _self.errorList(entry.getErrors('title')) }}
  </div>
    
  <div class="mb-6">
  <label for="featureImage" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Feature Image</label>
  
    {{ input('file', 'featureImage', entry.featureImage, {
      id: 'featureImage',
    }) }}
    {{ _self.errorList(entry.getErrors('featureImage')) }}
  </div>
  
  <div class="mb-6">
    <label for="postContent" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Tell us about your dog</label>
    {{ tag('textarea', {
      id: 'postContent',
      name: 'fields[postContent]',
      class:'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500',
    }) }}
    {{ _self.errorList(entry.getErrors('postContent')) }}
  </div>
  
  <div class="mb-8">
  <label for="postCategories" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Breed</label>
  <select name="fields[postCategories]" id="postCategories">
      {# Create a category query with the 'group' parameter #}
  {% set myCategoryQuery = craft.categories()
    .group('blog') %}
  {# Fetch the categories #}
  {% set categories = myCategoryQuery.all() %}
    {# display post categories #}
    {% if entry.postCategories|length %}
    <div class="border-t py-2 mb-6">
      {% for category in entry.postCategories.all() %}
        <a href="{{ category.url }}" class="inline-block border rounded px-2 py-1 text-sm">
          {{- category.title -}}
        </a>
      {% endfor %}
    </div>
    {% endif %}
    {% nav category in categories %}
      <li>
        <option>{{ category.title }}</option>
      </li>
    {% endnav %}  
  </select>
  </div>
  {#
  {% set field = craft.app.fields.getFieldByHandle('postCategories') %}
  
  {{ hiddenInput('fields[postCategories]', '') }}
  
  <select multiple name="fields[postCategories][]">
    {% for option in field.options %}
        {% set selected = entry is defined
          ? entry.postCategories.contains(option.value)
          : option.default %}
  
        <option value="{{ option.value }}"
          {% if selected %} selected{% endif %}
        >
          {{ option.label }}
        </option>
    {% endfor %}
  </select>
  #}
  <div class="mb-6">
    <button type="submit" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Publish</button>
  </div>
  </form>
  
  {% endblock %}
  
  ```
  
  **Tags:** frontend-form, params, entry-form
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-12-01. Score: 1 | Accepted answer
  
  You need to add `sectionId` to your form:
  
  ```
  {{ hiddenInput('sectionId', xx) }}
  
  ```
  
  If you have multiple entry types, you can also add `typeId` to the form:
  
  ```
  {{ hiddenInput('typeId', xx) }}
  
  ```
  
  For both examples, replace `xx` with an actual value, of course :)
  
  > **Comments:**
  > **username_0**: I did have that in initially but the craft example says to switch 'sectionId' for the id of the section you're posting to. So I changed it to 'blog' but got the error code. Am I supposed to leave  {{ hiddenInput('sectionId', '2') }} untouched and specify the blog somewhere else?  
  > **username_1**: You need to change `2` to your actual section id. You can find that by going to **Settings → Sections**, click your section then look at the number in your address bar. Alternatively, you'll find this in your database's `sections` table.  
  > **username_0**: That was what I was missing, thank you!!  
  
  ---
  
  