Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to send SMS using Twilio API services

dhanudjro
Participant
0 Kudos
1,467

Hi Experts,

Anyone worked in SAP building API with ABAP for using Twilio services to send SMS.

I have Account SID and Token for Twilio account.

Just need to send SMS(Reponse) not required. We have s4 Hana on-premise system.

Please give the steps and code if anyone already did.

7 REPLIES 7

Sandra_Rossi
Active Contributor
0 Kudos
1,365

Sandra_Rossi
Active Contributor
0 Kudos
1,365

Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

(or just edit your question via menu Actions > Edit)

Sandra_Rossi
Active Contributor
0 Kudos
1,365

You should first try with Postman or whatever software to make sure which exact HTTP requests send SMS successfully and then you do the same HTTP requests with ABAP.

dhanudjro
Participant
0 Kudos
1,365

It is not Business Accelerator hub, Just normal ABAP code to send SMS using Twilio.

I'm not sure about Business Accelerator hub, if we have it.

I tried using the class cl_http_client=>create_by_url and http_client->send, but not sure how to fill the url in the first method for Twilio services.

dhanudjro
Participant
0 Kudos
1,365

I'm trying to test with postman, can you help me the url details, i think i need to use POST for this, as i just need to send SMS. I have the Account SID and Test Auth Token.

Sandra_Rossi
Active Contributor
0 Kudos
1,365

You don't need Business Accelerator hub. I was just asking.

There should be all required information at Twilio.

Send messages with Messaging Services | Twilio

CURL is an easy way (via Cmd or Powershell).

Only after a successful run you can write the ABAP code.

Sandra_Rossi
Active Contributor
0 Kudos
1,365
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json"
--data-urlencode "Body=Hello from your Messaging Service$EXCLAMATION_MARK"
--data-urlencode "MessagingServiceSid=MG9752274e9e519418a7406176694466fa"
--data-urlencode "To=+15553332222"
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

--data-urlencode : to be appended to the URL (i.e. ...Messages.json?Body=Hello...&To=%2B15553332222)

(urlencode of + gives %2B)

-u : user and password (set_authorization)