BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JosephHenry
SAS Employee
Are you posing to a public URL that I could try?

Is there and example using cURL? if so, can you post it?
gvm
Calcite | Level 5 gvm
Calcite | Level 5

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.

JosephHenry
SAS Employee

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; 
ChrisHemedinger
Community Manager

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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
gvm
Calcite | Level 5 gvm
Calcite | Level 5

That did the trick. Thanks for the help.

When is support for multipart files coming to SAS?

JosephHenry
SAS Employee
Glad it is working now.

Multipart will be officially supported the next time I am allowed to add real features in a SAS release, but customer requests like this go a long way in getting features moved up in the priority list.
ssingh
SAS Employee

can anyone share sample code for authenticating user, get OAUTH tokens and finding file and folder IDs

ChrisHemedinger
Community Manager

@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

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 22 replies
  • 5296 views
  • 5 likes
  • 5 in conversation