Function API Call Syntax
# support
t
Hi Im trying to make an API POST Call to my flowise (langchain) server for functions to grab some info The POST Call works fine in Postman and all other apps im using it in but I cant seem to get this working inside of Vapi functions How do you make a basic POST API endpoint call to an external server and pass the raw body json?? Ive tried the make node and put my server url in and also the custom server options but theres no option I can see for raw POST calls using content application/json Now I can call this via python or javascript code but dont know what Vapi uses Heres a curl example - you cant test this ive hidden my server url. Can share via private messaging thanks curl https://xxxxx/api/v1/prediction/3a7c028d-df12-435d-a232-xxxx \ -X POST \ -d '{"question": "Hey, how are you?"}' \ -H "Content-Type: application/json"
v
Hi @thenumu, I'm an AI assistant for Vapi. While a team member reviews this question, I'll look through relevant sources and see if I can provide suggestions. Please tag @Vapi Support with any follow-up questions.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [Create Phone Call]() * [Call Functions]() * [Delete Phone Number]() * [Custom LLMs]() -----------------------------
### Answer In Vapi, to make a POST API call to an external server and pass raw JSON in the body within functions, you would typically define custom functions for your assistant. These custom functions can be configured to call external endpoints. When defining a custom function in the assistant configuration, you can specify the
serverUrl
to your external API endpoint. Additionally, you would manage the request details, including the method and body content, on your server or the endpoint that handles the function call from Vapi [(1)]() . Here's a conceptual example of defining a custom function in your assistant configuration:
Copy code
json
{
  "functions": [
    {
      "name": "fetchPrediction",
      "description": "Fetches prediction from external server",
      "parameters": {
        "type": "object",
        "properties": {
          "question": {
            "type": "string",
            "description": "The question for prediction"
          }
        }
      },
      "serverUrl": "https://your-server-url.com/handle-function"
    }
  ]
}
This example does not directly execute the POST request within Vapi but triggers a custom function that should be handled by your server. Your server would then construct and execute the POST request to the external API with the raw JSON body. Remember that the actual request to the external API, including setting the request method to POST and specifying the JSON body, would be implemented on your server, which receives the function call from Vapi. For specifics on making HTTP requests from your server, you would use your server-side technology's appropriate HTTP client capabilities, similar to how you might be using Postman or cURL for testing.
Got it. Tagging @User for additional help.
t
yes ive seen your AI answer but im trying to add the function via the dashboard and that seems to be for a coded vapi bot??