skip to Main Content

I am trying to figure out how the twillio sample curl -request actually works for SMS message. Here is a link to the “test” messages that you can use to make a request: https://www.twilio.com/user/account/developer-tools/api-explorer/message-create

Here is the curl post:

curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/accountsid/Messages.json' 
--data-urlencode 'To=phoneNumber'  
--data-urlencode 'From=+phoneNumber'  
--data-urlencode 'Body=Testing'  
-u accountsid:[AuthToken]

*Note: phoneNumber in the the To and From fields are actual numbers, same with the accountsid.

I am trying to find out what this url actually looks like?

What is the full URL? When I run this in the command line, it shows me a JSON type object which is what I would expect, I just am trying to get a visual of how this json object is attached to https://api.twilio.com/2010-04-01/Accounts/accountsid/Messages.json

I would imagine it would look something like:

https://api.twilio.com/2010-04-01/Accounts/accountsid/Messages.json&"To=phoneNumber"&"From=+phoneNumber"&"Body=Testing"&"accounsid:authtoken

I don’t think this url is 100% correct. When I run this and put this url in my browser I keep getting asked my credentials for Twilio, I put in the correct username and password and it rejects it.

2

Answers


  1. Twilio evangelist here.

    Can you clarify what you mean when you say “what this url actually looks like”.

    The curl sample you provide makes an Basic authenticated HTTP POST to the Messages resource. You use this kind of request to send an SMS message. The response to that request, Twilio returns to you a Message object encoded as JSON.

    If you just paste that same URL into a browser and press enter there will be two differences between that and the CURL request:

    1. The browser will make an HTTP GET, not and HTTP POST to the Messages resource.
    2. The browser will not include the basic authentication credentials, which is why you are getting prompted to enter them

    Hope that helps.

    Login or Signup to reply.
  2. You can try like

    https://userid:[email protected]/?param

    When you want to authenticate your request using basic Auth in browser.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search