breezyB

API POST to PHP file doesn't do anything

I have created an agent that uses an API to POST data to a PHP file as form data. The PHP file is supposed to take the form data that are passed to it from Voiceflow and create a new row in a sql database. I have tested the PHP file at length, it works great if I pass data to it from an HTML form. However, when I run the agent, and have Voiceflow POST the data to the PHP file nothing happens. The chat interface runs smoothly, no errors, looks like everything worked, but nothing is written to the database. The headers are "Content-Type" and "application/x-www-form-urlencoded", the body is set to "Form Data"", and I am passing one variable. When I test the API in Voiceflow I get:

Body
{
"VF_STATUS_CODE": 200,
"VF_HEADERS": {
"connection": "Upgrade, close",
"content-encoding": "gzip",
"content-length": "2894",
"content-type": "text/html; charset=UTF-8",
"date": "Fri, 21 Jun 2024 23:35:08 GMT",
"server": "Apache",
"upgrade": "h2,h2c",
"vary": "Accept-Encoding",
"x-powered-by": "PHP/7.2.34"
}
}

Headers
content-type
application/json; charset=utf-8

I have worked on this for two days and cannot seem to overcome this problem. The test shows Header as "application/json; charset=utf-8", but in the API Header I entered is "application/x-www-form-urlencoded". Does the Voiceflow API POST JSON objects or form data when I set "Content-Type" to "application/x-www-form-urlencoded"?

I am a novice and may be missing something obvious to other users. Thank you in advance for any advice you can provide.
Was this page helpful?