BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
EyalGonen
Barite | Level 11

I need to upload a file from my local disk to a SAS Content folder. I am using the SAS REST APIs for this.

 

I am a bit confused reading the API doc on https://developers.sas.com. On the one hand in the "folders" API there is an option to add a "member" to an existing folder. On the other hand, on the "files" API there is an option to create a new file. Not sure what to use and what is the relationship between the two.. Any advice?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
gwootton
SAS Super FREQ
The files service has an optional parentFolderUri query parameter you can use to specify the folder the file should be added to (/folders/folders/folder_id), but uploading a file does not require it be referenced by SAS Content (folders service). When you specify parentFolderUri, the files service will call the folders service to confirm there is not already a file with that name in the folder, and add the file as a member for you if it is not already a member of that folder.
--
Greg Wootton | Principal Systems Technical Support Engineer

View solution in original post

8 REPLIES 8
gwootton
SAS Super FREQ
The files service has an optional parentFolderUri query parameter you can use to specify the folder the file should be added to (/folders/folders/folder_id), but uploading a file does not require it be referenced by SAS Content (folders service). When you specify parentFolderUri, the files service will call the folders service to confirm there is not already a file with that name in the folder, and add the file as a member for you if it is not already a member of that folder.
--
Greg Wootton | Principal Systems Technical Support Engineer
joeFurbee
Community Manager

Hi @EyalGonen,

You can use the Upload a file end point under the dataTables API. I'm attaching a Postman collection with example usage. Look in step 2. upload data for an example.


Join us for SAS Community Trivia

SAS Bowl LXI - SAS at 50 and SAS Innovate Recap
Wednesday, May 27, 2026 at 10 am ET.
EyalGonen
Barite | Level 11

Hi @joeFurbee 

 

I need to upload text files such SAS programs or binary files like JPG files. Is your solution appropriate for these use cases?

joeFurbee
Community Manager

Hi @EyalGonen,

Yes, a text file should be fine. In my example (see below) I use a csv file. In order to provide the file path, I went to the Body section, created a new file Key and provided the path from my client as the Value.

joeFurbee_1-1720708193890.png

 

I've not tried with .jpg. Would be interested if that works or not.

 


Join us for SAS Community Trivia

SAS Bowl LXI - SAS at 50 and SAS Innovate Recap
Wednesday, May 27, 2026 at 10 am ET.
EyalGonen
Barite | Level 11

Hi @joeFurbee @gwootton 

 

Sorry for the (very) late reply...

I just came back to this (doing it on my free time) and I am using this API: https://developer.sas.com/rest-apis/files/createNewFile to upload local client files to the SAS Files service and in addition I am  passing the parentFolderUri parameter as explained here  https://developer.sas.com/rest-apis/files/createNewFile#query-parameters  to attach the uploaded file to some SAS Content folder.

This works BUT I cannot find a way to specify the filename to be displayed in the SAS Content folder. The uploaded file appears in the SAS Content folder with this name: FileResource1779021791076 where the digits are changing with each file I upload.

I am testing on Viya 3.5 so maybe it is different for SAS Viya.

 

Any idea how to control the uploaded filename as seen in the SAS Content folder?

gwootton
SAS Super FREQ
@EyalGonen you can pass the file name in the "Content-Disposition" header. e.g. Content-Disposition: filename="test.txt"
--
Greg Wootton | Principal Systems Technical Support Engineer
EyalGonen
Barite | Level 11

Hi @gwootton 

 

Thanks! It works now!

 

I have one more question about the query parameter "typeDefName" here: https://developer.sas.com/rest-apis/files/createNewFile#query-parameters.

Where can I find the possible values for this parameter? 

All files I uploaded are with type="file" in SAS Content and I want to change at least for SAS programs. 

gwootton
SAS Super FREQ
You could call the REST API /types/types to retrieve all the types defined in the types registry. The "name" attribute for each would be what could be used in typeDefName.
--
Greg Wootton | Principal Systems Technical Support Engineer