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

Hi Community, 

 

I'm new to SAS Viya and how it workds. I have a repository containing many SAS related files, jobs and reports. I want to create a python script to use SAS Viya APIs to load the files into SAS Viya. I looked into the documentation and I've found the /files/files endpoint to create a new resource file. I did a successful request by using this endpoint and I see a

creationTimeStamp property in the response. However, when I search  for the object and open the file in the SAS Environment Manager, I receive the error that SAS Environment Manager. I see the file in the search results. 
 
MAhkami_0-1743578999839.png

 

I only used the /files/files endpoint createNewFile | SAS for Developers to create this file. Is this the right approach? 

In general, what steps do I need to take to import a file to SAS Viya with API requests? Also, can someone tell me how I can distinguish different SAS scripts from each other (reports, jobs, scripts)?

 

Thanks,

Mehran

 

 

 

 
1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

Publicly documented API's can be found here https://developer.sas.com/rest-apis

 

The /transfer API as seen in Moving SAS® Viya® Contents: A RESTful Way - SAS Support Communities is not publicly available.  So the documented way of doing an import, is to use the sas-viya transfer plugin.

View solution in original post

5 REPLIES 5
BrunoMueller
SAS Super FREQ

Some questions:

  • What kind of files do you want to import?
  • Are these plain text files that contain SAS program code?
  • Are these files (.json) created by exporting SAS content folders or members within a SAS Content folder?

When adding plain text files did you specify the parentFolderUri query parameter?

MAhkami
Calcite | Level 5

So, the files I want to import are not plain txt files and they have json format. I assume that they are  exported by SAS content folders. I see different type tags in the json file such as "application/vnd.sas.transfer.object", "application/vnd.sas.file", and many more. I did not provide the parentFolderUri in the header part of my request. I did not see this requirement in the documentation. Is it necessary to provide this?

BrunoMueller
SAS Super FREQ

So they seem to be SAS packages. These files can be imported using the sas-viya CLI using the transfer plugin.

To make things easier check this https://github.com/sassoftware/pyviyatools/blob/master/importpackages.py it does the thing you are looking for. It uses the sas-viya CLI in the background to the work.


MAhkami
Calcite | Level 5

Thanks. Does it mean that I cannot import SAS packages with Rest APIs? 
I've seen this approach before and I thought an endpoint is available to transfer these files. I found this link from the community. 
Moving SAS® Viya® Contents: A RESTful Way - SAS Support Communities

Are SAS packages a special type of file in SAS which can only be imported with CLIs?

BrunoMueller
SAS Super FREQ

Publicly documented API's can be found here https://developer.sas.com/rest-apis

 

The /transfer API as seen in Moving SAS® Viya® Contents: A RESTful Way - SAS Support Communities is not publicly available.  So the documented way of doing an import, is to use the sas-viya transfer plugin.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Discussion stats
  • 5 replies
  • 2233 views
  • 0 likes
  • 2 in conversation