0

im sending a POST request to this URL: https://verify.twilio.com/v2/Services/[REDACTED]/Verifications

and with that POST request I'm setting the required parameters in a JSON Object as the body. My issue is that when I send the request with all the correct required parameters like this

{
    "To": "[REDACTED VALID PHONE NUMBER]",
    "Channel": "sms"
}

I get the following error.

{
  "code": 20001,
  "message": "Missing required parameter To in the post body",
  "more_info": "https://www.twilio.com/docs/errors/20001",
  "status": 400
}

If I try using Insomnia and setting the body to MultiPartForm and type in all my required parameters just like before it works. The issue is I cant use multipart forms and I need to use JSON, anyone have an idea why the API is acting like this?

Here is the API docs: https://www.twilio.com/docs/verify/api/verification

After further testing, YAML and XML don't work either.

Maloni
  • 27
  • 4

1 Answers1

0

This answer isn't very satisfying, but this is how the API works. It would be best if you used content-type=application/x-www-form-urlencoded as it is also done in the documented samples.

It would be nice if it were explicitly mentioned somewhere like it was in the past.

Here's a suggestion then, build yourself a Node.js Twilio Function that takes in a webhook from Twilio, translates the content from application/x-www-form-urlencoded to application/json, and sends it on to your application

IObert
  • 2,118
  • 1
  • 10
  • 17