Search code examples
twiliotwilio-apitwilio-conversations

Twilio - Missing required parameter FriendlyName in the post body


I am trying to create a conversation server in Twilio. I created the basic authentication header and I am trying to create a conversation service using a post call to the api exactly as the documentation suggested.

enter image description here

I am getting an error (status 400) and a message that says:

Missing required parameter FriendlyName in the post body

I am sending the friendlyName to the body. I tried changing the content-type to x-www-form-urlencoded and to add data before the {friendlyName: 'name'} but I still getting this message. I also tried to change the body to {data: {friendlyName: 'name'}} and to wrap it all with JSON.stringify but I keep getting this message.


Solution

  • The documentation has a CURL example, I tried it and it worked:

    It is application/x-www-form-urlencoded.

    Create Conversation

    curl -X POST https://conversations.twilio.com/v1/Conversations \
    --data-urlencode "MessagingServiceSid=MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
    --data-urlencode "FriendlyName=Friendly Conversation" \
    -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN