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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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