VAPI API post req function isnt working
# support
r
I've tried several hours reading through the documentaions and trying everything i could ...but this one function isnt working at all..whenever im adding the function the website is crashing someone please help https://cdn.discordapp.com/attachments/1377625161020473355/1377625161980711055/image.png?ex=6839a4e9&is=68385369&hm=d1e6c5faf8af07670d4916821e6cf1c79e71b080d117430f08264d2393b26d04&
v
Try this minimal POST handler for your
/api/generate
endpoint:
Copy code
js
app.post("/api/generate", async (req, res) => {
  try {
    // Your logic here
    res.json({ success: true, questions: [] }); // Example response
  } catch (e) {
    res.status(500).json({ error: "Internal server error" });
  }
});
Make sure your server always responds within 7.5 seconds, even on error, to prevent Vapi from crashing your site. This should help you debug if the crash is due to missing or delayed responses. Reference: [Vapi error handling and server requirements](https://docs.vapi.ai/assistants/personalization#error-handling) Source: - [Personalization with user information (Vapi docs)](https://docs.vapi.ai/assistants/personalization)
Try this minimal POST handler for your
/api/generate
endpoint:
Copy code
js
app.post("/api/generate", async (req, res) => {
  try {
    // Your logic here
    res.json({ success: true, questions: [] }); // Example response
  } catch (e) {
    res.status(500).json({ error: "Internal server error" });
  }
});
Make sure your server always responds within 7.5 seconds, even on error, to prevent Vapi from crashing your site. This should help you debug if the crash is due to missing or delayed responses. Reference: [Vapi error handling and server requirements](https://docs.vapi.ai/assistants/personalization#error-handling) Source: - [Personalization with user information (Vapi docs)](https://docs.vapi.ai/assistants/personalization)
Check your tool configuration and server response format. Your
tools
array should include your function like this:
Copy code
json
{
  "type": "function",
  "function": {
    "name": "generate_interview",
    "parameters": {
      "type": "object",
      "properties": {
        "type": { "type": "string" },
        "userId": { "type": "string" }
      }
    }
  },
  "async": false,
  "server": { "url": "http://192.168.56.1:13000/api/generate" }
}
Your server must respond with:
Copy code
json
{
  "results": [
    { "toolCallId": "X", "result": "Y" }
  ]
}
Make sure your endpoint is publicly accessible and responds within 7.5 seconds, or the function will fail and may crash the site. [See the Custom Tools Guide for details.](https://docs.vapi.ai/tools/custom-tools) Source: - [Custom Tools Guide](https://docs.vapi.ai/tools/custom-tools)
Check your tool configuration and server response format. Your
tools
array should include your function like this:
Copy code
json
{
  "type": "function",
  "function": {
    "name": "generate_interview",
    "parameters": {
      "type": "object",
      "properties": {
        "type": { "type": "string" },
        "userId": { "type": "string" }
      }
    }
  },
  "async": false,
  "server": { "url": "http://192.168.56.1:13000/api/generate" }
}
Your server must respond with:
Copy code
json
{
  "results": [
    { "toolCallId": "X", "result": "Y" }
  ]
}
Make sure your endpoint is publicly accessible and responds within 7.5 seconds, or the function will fail and may crash the site. [See the Custom Tools Guide for details.](https://docs.vapi.ai/tools/custom-tools) Source: - [Custom Tools Guide](https://docs.vapi.ai/tools/custom-tools)
Try this: Make sure your
/api/generate
endpoint responds to Vapi's POST request with a valid JSON object like:
Copy code
json
{ "result": "Your generated interview questions here." }
If your server doesn't respond within 7.5 seconds or returns invalid JSON, the call may fail or crash the site. Double-check your endpoint and error handling. [See function call handling in the docs.](https://docs.vapi.ai/server-url/events#function-calling) Source: - [Vapi Server Events: Function Calling](https://docs.vapi.ai/server-url/events#function-calling)
Try this: Make sure your
/api/generate
endpoint responds to Vapi's POST request with a valid JSON object like:
Copy code
json
{ "result": "Your generated interview questions here." }
If your server doesn't respond within 7.5 seconds or returns invalid JSON, the call may fail or crash the site. Double-check your endpoint and error handling. [See function call handling in the docs.](https://docs.vapi.ai/server-url/events#function-calling) Source: - [Vapi Server Events: Function Calling](https://docs.vapi.ai/server-url/events#function-calling)
Thanks for sharing the details! To help you further, could you please share the exact error message or browser console output you see when the website crashes after adding the POST request function? This will help pinpoint the issue more accurately. Sources: - [Vapi Personalization Documentation](https://docs.vapi.ai/assistants/personalization) - [Vapi Server Events](https://docs.vapi.ai/server-url/events)
Thanks for sharing the details! To help you further, could you please share the exact error message or browser console output you see when the website crashes after adding the POST request function? This will help pinpoint the issue more accurately. Sources: - [Vapi Personalization Documentation](https://docs.vapi.ai/assistants/personalization) - [Vapi Server Events](https://docs.vapi.ai/server-url/events)
c
Hey, really sorry for your experience. If possible, could you record a loom video describing this error/behavior or inconsistency in the dashboard with the steps to reproduce it? That way, I can share this with my team, and we'll take a look. We'll even try to reproduce the same so we can fix it for you. Also, I'll request you to share your assistant ID and tool ID.
r
its ok.. i have replaced vapi with a normal form fill in the website and ... im so done with it ... but what i think needs to be fixed rn is the site man the workflow can not be attached like before now .. and the tools are also not working at all the save button gives an error always and the responsiveness of the website for smaller screen sizes is pretty messed up... please fix these issue asap... vapi was better before the recent updates..
c
We sincerely apologize for all of the changes as we heavily rework all of the new functionality for production use-cases. Workflows are undergoing some changes to bring it out of beta, and the tools for API requests issue has been resolved and released on weekly update channels. If you would like to provide a loom recording for your screen size issue, we will gladly review it and let our development team know so we can better improve our platform.
2 Views