• Hi,

    We’re using wp rest api v2 in the website for api and we need to use contact form 7 route

    wp-json/contact-form-7/v1/contact-forms/1299

    The route is successfully authorized and returning all the properties and their values when we’re trying through GET request in postman.
    But when trying to send information through POST request it sends nothing and no error.

    Here is the properties we are trying in the body tab of postman

    
    properties.mail.recipient: [email protected]
    properties.mail.subject: Error log of the project
    properties.mail.sender: Project log
    properties.mail.body: Take a peak about error log
    

    We also tried by setting a fixed value for “To”, “From”, “Subject” in contact form 7 Mail panel of WordPress dashboard. And send the information in “Message Body” with the parameter called body like this:

    
    properties.mail.body: Take a peak about error log
    

    When we check server log it shows success code for every POST request and no error but we are not getting any email.
    We’ve even tried by changing different emails.

    Please tell me what is the best possible way to send POST request for Contact form 7 routes.

    Thanks for your help.

    • This topic was modified 6 years, 3 months ago by Irfan_25.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Did you ever get this figured out? I get an error when trying to get:
    wp-json/contact-form-7/v1/contact-forms/61

    error is:

    
    {
      code: "wpcf7_forbidden",
      message: "You are not allowed to access the requested contact form.",
        data: {
          status: 403
        }
    }
    

    It seems like you’re required to authenticate before using the REST API endpoints of contact form 7. This is quiet a challenge if you’re not working inside the WordPress environment (as it is in my case).

    To be able to receive data from the wpcf7 REST API endpoints you will need to authenticate with the WordPress REST API. Note that this is not done automatically after logging in, you will also need to generate a nonce as following: wp_create_nonce( 'wp_nonce' );. Every request you make to the API should include a X-WP-Nonce header with that nonce key.

    To generate a nonce while working in the WordPress environment it should not be a problem because you can call this function. If you’re working in another environment like me than you will probably have to create an extra endpoint to retrieve the nonce.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘POST request contact form 7 route’ is closed to new replies.