BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Assaf_Attas
Obsidian | Level 7

hi friends,

 

does anyone has any experience with Twilio or any other kind of SMS API's ?

 

i'm trying to figure how to pass a "new line" to the api

 

already tried \n and '0A'x ... it just pass then as plain text and not as special characters

 

proc http 
	method=POST
	url="&url"
	in = form 	(
				"From" 	="&from"
				"To" 	="&to"
				"Body" 	="&sms_body"
				)
	out=rrespons
	headerout=hdrout
	WEBUSERNAME="&sid_account"
	WEBpassword="&token"
	auth_basic
	;
	DEBUG LEVEL=3 REQUEST_BODY REQUEST_HEADERS;
	
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Assaf_Attas
Obsidian | Level 7

I think i found the solution..

the problem was that sas tries to url encode the already url encoded character.

 

the solution is to selectively pre urlencode

data _null_;
	length msg_txt $ 256;
	msg_txt = urlencode("Go to") || '%0A' || urlencode("New Line");

	/* or even shorter ...*/
	msg_txt = urlencode("Go to" || byte(10) || "New Line");

	call symput('msg_txt', msg_txt);
run;
%put &msg_txt;

 

combined with using the proc http NOENCODE option

proc http 
	method=POST
	url="&url"
	in = form 	(
				"From" 	="&from"
				"To" 	="&to"
				noencode "Body" 	="&msg_txt"
				)

	;
run;

@EyalGonen 

@Hagay 

 

View solution in original post

4 REPLIES 4
Hagay
SAS Employee

Hello Assaf,

 

didn't work with Twilio myself but according to this:

https://support.twilio.com/hc/en-us/articles/223181468-How-do-I-Add-a-Line-Break-in-my-SMS-or-MMS-Me...

you need to add a $ sign to the beginning of the message to have your special characters to work.

 

Hagay

Assaf_Attas
Obsidian | Level 7

hi hagay,

 

using $ sign is for cUrl..

i guess i'm looking for the sas equivalent for protecting special characters in proc http

Assaf_Attas
Obsidian | Level 7

I think i found the solution..

the problem was that sas tries to url encode the already url encoded character.

 

the solution is to selectively pre urlencode

data _null_;
	length msg_txt $ 256;
	msg_txt = urlencode("Go to") || '%0A' || urlencode("New Line");

	/* or even shorter ...*/
	msg_txt = urlencode("Go to" || byte(10) || "New Line");

	call symput('msg_txt', msg_txt);
run;
%put &msg_txt;

 

combined with using the proc http NOENCODE option

proc http 
	method=POST
	url="&url"
	in = form 	(
				"From" 	="&from"
				"To" 	="&to"
				noencode "Body" 	="&msg_txt"
				)

	;
run;

@EyalGonen 

@Hagay 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Discussion stats
  • 4 replies
  • 964 views
  • 1 like
  • 3 in conversation