Support » Plugin: Contact Form 7 » posting through rest api

  • Hello,

    When I do a post request on postman, the contactform7 is working

    var data = new FormData();
    data.append("your-email", "");
    data.append("your-name", "fwwfwfwffw");
    var xhr = new XMLHttpRequest();
    xhr.withCredentials = true;
    xhr.addEventListener("readystatechange", function () {
      if (this.readyState === 4) {
    });"POST", "http://domain.local/wp-json/contact-form-7/v1/contact-forms/5/feedback");
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xhr.setRequestHeader("cache-control", "no-cache");
    xhr.setRequestHeader("Postman-Token", "43831d25-f107-4ab9-b5ad-2f9fecdbee78");

    Gives me:

        "into": "#",
        "status": "mail_sent",
        "message": "Thank you for your message. It has been sent."

    5, in the url is the ID of my form.
    But when I use this within my development site
    I got

    {"into":"#","status":"validation_failed","message":"One or more fields have an error. Please check and try again.","invalidFields":[{"into":"span.wpcf7-form-control-wrap.your-name","message":"The field is required.","idref":null},{"into":"span.wpcf7-form-control-wrap.your-email","message":"The field is required.","idref":null}]}

    Documentation on using contactform7 with the rest api, or plain javascript requests is very hard to find


Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.