0
votes

When creating a Channel the REST API seems to ignore any data in requests with a JSON body. Example:

curl -X POST https://chat.twilio.com/v2/Services/{instance sid}/Channels -H 'authorization: Basic blah blah blah' -H 'content-type: application/json' -d '{ "friendly_name": "Test Chat One", "type": "private" }'

Does the API not support JSON requests? The docs show requests with post with form data https://www.twilio.com/docs/api/chat/rest/channels?code-sample=code-create-a-channel&code-language=curl&code-sdk-version=default but not JSON??

Have I missed something?

Ta

1

1 Answers

0
votes

Twilio developer evangelist here.

The Twilio API does not support JSON requests (though it will respond with JSON if you ask it to).

Check the documentation on the API here. It says:

In the PUT or POST, you represent the properties of the object you wish to update as form urlencoded key/value pairs. Don't worry, this is already the way browsers encode POSTs by default. But be sure to set the HTTP Content-Type header to "application/x-www-form-urlencoded" for your requests if you are writing your own client.