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: 
Read only

How to send SMS using Twilio API services

dhanudjro
Participant
0 Likes
3,357

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
Read only

Sandra_Rossi
Active Contributor
0 Likes
3,255
Read only

Sandra_Rossi
Active Contributor
0 Likes
3,255

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)

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,255

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.

Read only

dhanudjro
Participant
0 Likes
3,255

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.

Read only

dhanudjro
Participant
0 Likes
3,255

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.

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,255

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.

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,255
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)