51%macro ms_triggerstp(pgm
56 ,outds=work.ms_triggerstp
59 %local dbg mainref authref boundary libref triggered_sid;
60 %let mainref=%mf_getuniquefileref();
61 %let authref=%mf_getuniquefileref();
62 %let boundary=%mf_getuniquename();
63 %
if &inputparams=0 %then %let inputparams=_null_;
65 %
if &mdebug=1 %then %
do;
66 %put &sysmacroname entry vars:;
72 %mp_abort(iftrue=(
"&pgm"=
"")
74 ,msg=%str(Program not provided)
76 %mp_abort(iftrue=(
"&outds"=
"")
78 ,msg=%str(Output dataset not provided)
83 %let optval=%sysfunc(getoption(bomfile));
88 file &mainref termstr=crlf lrecl=32767 mod;
89 length line $1000 name $32 value $32767;
90 if _n_=1 then call missing(of _all_);
93 line=cats(
'Content-Disposition: form-data; name="',name,
'"');
103 set &inputfiles end=last;
104 length fileref $8 name $32 filename $256;
105 call symputx(cats(
'webref',_n_),fileref,
'l');
106 call symputx(cats(
'webname',_n_),name,
'l');
107 call symputx(cats(
'webfilename',_n_),filename,
'l');
109 call symputx(
'webcount',_n_);
110 call missing(of _all_);
116 %
do i=1 %to &webcount;
118 file &mainref termstr=crlf lrecl=32767 mod;
119 infile &&webref&i lrecl=32767;
123 'Content-Disposition: form-data; name="'
131 put
"Content-Type: text/plain";
141 file &mainref termstr=crlf mod;
142 put /
"--&boundary--";
146 file &authref lrecl=1000;
147 infile
"&_sasjs_tokenfile" lrecl=1000;
149 if _n_=1 then put
"Content-Type: multipart/form-data; boundary=&boundary";
153 %
if &mdebug=1 %then %
do;
155 if _n_ eq 1 then putlog
"NOTE: ***** authref=&authref content *****";
160 if _n_ eq 1 then putlog
"NOTE: ***** mainref=&mainref content *****";
167 %local resp_path outref;
168 %let resp_path=%sysfunc(pathname(work))/%mf_getuniquename();
169 %let outref=%mf_getuniquefileref();
170 filename &outref
"&resp_path" lrecl=32767;
173 proc http method=
'POST' headerin=&authref in=&mainref out=&outref
174 url=
"&_sasjs_apiserverurl/SASjsApi/stp/trigger?%trim(
175 )_program=&pgm%str(&)_debug=&debug%str(&)expiresAfterMins=&expiresaftermins";
176 %
if &mdebug=1 %then %
do;
181 %
if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
185 if _n_ eq 1 then putlog
"NOTE: ***** outref=&outref content *****";
192 iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200
193 and &SYS_PROCHTTP_STATUS_CODE ne 201)
195 ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
201 %let libref=%mf_getuniquelibref();
202 libname &libref JSON fileref=&outref;
203 %let triggered_sid=%mf_getuniquename(prefix=triggered_sid_);
205 data work.&triggered_sid (keep=sessionid);
208 %
if &mdebug=1 %then %
do;
213 %
if %mf_nobs(work.&triggered_sid)>0 %then %
do;
214 proc append base=&outds data=work.&triggered_sid;
218 %
if &mdebug=1 %then %
do;
219 %put &sysmacroname exit vars:;
227 libname &libref clear;
229 %mp_dropmembers(&triggered_sid,libref=work);