Here is a curl request that works just fine:
curl -v -X POST --header "Authorization: Token ${TOKEN}" -F file=@/home/data/tests/testdata/dataset.xlsx ${URL}
Sadly, it's not a public URL at the moment.
So it looks like one small thing was missing. there needed to be an extra CRLF before the final boundary, which can be achieved with one additional "put ;" before the output of the final boundary.
This is the entire code that I ran in my tests:
%let boundary=%sysfunc(uuidgen());
filename in "/temp/multipart_data.dat";
data _null_;
file in termstr=CRLF;
if _n_ = 1 then do;
put "--&boundary.";
put 'Content-Disposition: form-data; name="file"; filename="data.xlsx"';
put 'Content-Type: application/octet-stream';
put ;
end;
run;
data _null_;
file in mod recfm=f lrecl=1;
infile "/temp/tags" recfm=f lrecl=1;
input;
put _infile_;
run;
data _null_;
file in mod termstr=CRLF;
put;
put "--&boundary--";
run;
proc http
method="post"
url = "httpbin.org/post"
in = in
ct="multipart/form-data; boundary=&boundary."
HEADEROUT_OVERWRITE;
;
run;
Not for nothing...but I found that the Box APIs are very picky. No wiggle room in the implementation to vary from the exact content it expects. That's true for the APIs to get a refresh token, query content, and post content. I've been trying (off and on) to work up a SAS example, but it's tricky to find a path that I'm confident will work in most scenarios.
That did the trick. Thanks for the help.
When is support for multipart files coming to SAS?
can anyone share sample code for authenticating user, get OAUTH tokens and finding file and folder IDs
@ssingh It's best to ask a new question since this one is solved. However, OAuth mechanisms are similar across different services, so you might find this article useful.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: