Happily, that will not be necessary! I was able to get it to work with a couple of small modifications. I will share them below: @ChrisHemedinger's response about what the data _null_ step was doing in relation to cURL was the big aha moment. At that point, we needed to translate both the path parameter and the type parameter that was being passed in to the form to something that worked within the data _null_ framework that you presented. So, the first thing I did was took Chris's suggestion and incorporated that into the boundary macro variable: /*Set up the form parameters*/
%let boundary=%sysfunc(uuidgen()); Then, the next important part was to make sure that the name passed through the block of metadata matched the name of the parameter that the API was looking for and that there was a matching file name. Since the data _null_ was doing the unpacking for me, I just needed to make sure that the data had the same parameter name that the API was looking for. data _null_;
infile Contact /*This represents the json file containing the contacts and was defined in an earlier fileref*/
end=eof;
file in;
if _n_ = 1 then do;
put "--&boundary.";
put 'Content-Disposition: form-data; name="contacts"; filename="contact_upload.json"';
put 'Content-Type: application/json';
put ;
end;
input;
put _infile_;
put ;
if eof then do;
put ;
put "--&boundary.--";
end;
run; And then I needed to specify the type. You had already put the header that specified the content type in the program, it just needed to be changed to a different type. With that it works! Thank you both so much, this will be a huge time saver! For those interested, below is the full code: filename resp2 '\\path\to\APIoutput\response.txt';
filename in TEMP;
/*Set up the form parameters*/
%let boundary=%sysfunc(uuidgen());
data _null_;
infile Contact /*This represents the json file containing the upload data and was defined in an earlier fileref*/
end=eof;
file in;
if _n_ = 1 then do;
put "--&boundary.";
put 'Content-Disposition: form-data; name="contacts"; filename="contact_upload.json"';
put 'Content-Type: application/json';
put ;
end;
input;
put _infile_;
put ;
if eof then do;
put ;
put "--&boundary.--";
end;
run;
proc http method="POST"
url="&link"
in=in
ct="multipart/form-data;boundary=&boundary."
out=resp2;
headers
"X-API-TOKEN"="tokenwenthere";
run;
... View more