• Resolved nitin421503

    (@nitin421503)


    I’m using WordPress as a headless CMS and using Contact Form 7 for my form needs.

    I recently updated it to version 5.8.7 from 5.8.5, which was a minor update. (I assumed)
    But with the update, all my form submissions stopped working. Therefore, I downgraded the plugin.

    I looked to change the log and found there was some restriction added to REST API: Returns 400 Bad Request if no valid unit tag is included in the form submission.

    I am not sure what a valid unit tag is or how I can fix it for my website.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Just post one more parameter named _wpcf7_unit_tag with any non-empty value.

    Thread Starter nitin421503

    (@nitin421503)

    Thanks Madex, your solution worked.

    Hello,

    just faced the same problem, solution also worked, but I can’t find the information what is the purpose of this unit tag?

    Hello, thank you for the solution.

    Adding ‘_wpcf7_unit_tag’ to the POST request solves the issue.

    This tag was implemented in February’s update — https://contactform7.com/2024/02/05/contact-form-7-587/.

    When I asked ChatGPT for help I got this answer:

    The _wpcf7_unit_tag is a hidden field that Contact Form 7 uses for internal tracking. When you submit a form, Contact Form 7 expects this field to be included in the POST request. The value of this field is usually a string that starts with wpcf7-f followed by the form ID and a dash - and then a random number.

    If you’re making a POST request manually (like in your Next.js code), you’ll need to include this field in your formData object. The value can be any non-empty string, but it’s a good practice to follow the format that Contact Form 7 uses.

    Here’s how you can modify your formData object to include the _wpcf7_unit_tag field:

    
    let formData = {
      // your other form fields here...
      _wpcf7_unit_tag: 'wpcf7-f' + formId + '-123'
    };

    In this example, replace formId with the actual ID of your form and 123 with any random number. Then, you can use this formData object in your fetch request.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Returns 400 Bad Request for POST Request Method.’ is closed to new replies.