plain-purple•2y ago
For the pro Javascript users - help?
Hoping to get help on this
this is an array and I am struggling to put this into the body of a Post API call. Any advice on how I could do this?
patient_phone_numbers: [
{
phone_type: 'Mobile',
number: '0-123-456-78'
}
]
})
I've tried doing this directly under 'Raw' but it's not working cuz obviously, I don't know what I am missing lol. I'm getting 400 bad request

9 Replies
Based on your expertise level and the context provided, it seems like you're trying to make a POST request using the Voiceflow Fetch API in JavaScript. Here's how you can do it:
In this example, the
fetch
function is used to make a POST request to the specified URL. The method
property in the options object is set to 'POST', indicating the type of request. The headers
property is used to set the 'Content-Type' to 'application/json', which tells the server that the request body contains JSON data. The body
property contains the JSON stringified version of your data.
If you're still getting a 400 bad request error, it might be due to the server not accepting the request for some reason. This could be due to the server expecting different data, or there might be an issue with the server itself. You might want to check the API documentation or reach out to the API provider for more information.
Sources:
- Voiceflow Fetch APIplain-purpleOP•2y ago
how do you add this into the Form Data of the Body?
You need to capture the number in a variable then use 'form data' in your body to send the info. similar to this:

plain-purpleOP•2y ago
thanks for your reply.
yeah, I've done that for the rest and they work perfectly. But the only one that I am struggling with has an array that i need to follow from a documentation and I can't seem to figure out how to put them together in the Form Data.

plain-purpleOP•2y ago
thoughts @NiKo | Voiceflow @Daniel ?
Right gotcha, You need to send the array in another api step with raw body, you can't mix and match. Do it like this:


plain-purpleOP•2y ago
@Steve B. | IntelleSync.ai Although I had to send another call as a Patch API request, that worked like a charm. Thanks, Steve!
Great glad it worked out!