metropolitan-bronze•16mo ago
Problem with data formatting in Voiceflow API block POST request
Hi,
I am encountering a problem when performing POST request from voiceflow API block to my server. When I enter the data in json format in the 'Raw' section of body it works, but when I enter it in the 'Form Data', it gives a content type error.
I need to use the form data format because it allows me to send voiceflow variable to my server.
Could anyone please help me with that?
2 Replies
To resolve the issue you're encountering with the Voiceflow API block when performing a POST request, follow these steps:
1. Use JSON Format in 'Raw' Section:
- Ensure that your data is correctly formatted as JSON when using the 'Raw' section. This is the preferred method for sending structured data.
2. Form Data Format:
- If you need to use the 'Form Data' format to send Voiceflow variables, make sure that the content type is set correctly. The 'Form Data' format typically requires
Content-Type: application/x-www-form-urlencoded
.
3. Setting Headers:
- In the API block, add the appropriate headers for the 'Form Data' format. Here’s how you can set it up:
4. Formatting Data for 'Form Data':
- When using 'Form Data', ensure that your data is URL-encoded. For example, if you have a JSON object like this:
Convert it to a URL-encoded string:
5. Example Setup in Voiceflow:
- In the API block, select the 'Form Data' option and enter your data in the key-value pairs. Ensure the keys match the expected parameters on your server.
6. Troubleshooting:
- Double-check your server's requirements for content types and data formats. Use tools like Postman to test your API calls independently before implementing them in Voiceflow.
By following these steps, you should be able to successfully send data using the 'Form Data' format in Voiceflow's API block without encountering content type errors.You can send vars in the raw body too. Just enter it like: