- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 05-12-2020 02:39 PM
(2751 views)
Hi,
I am looking for a way of creating a list of SAS reports and their parent locations. I guess the way to go is to search for the folders where the reports are by using REST API calls, but I could not find a way of developing a SAS job for it.
I have a list of my Viya reports (http://sasviya35.example.local/reports/reports) in .json format. Through a Rest API call using PROC HTTP, i.e.:
filename jsonout temp;
proc http
url=" http://sasviya35.example.local/reports/reports "
method="get"
oauth_bearer=sas_services
out=jsonout;
run;
libname reports json fileref=jsonout;
proc print data=reports.items;
run;
it is possible to output some information (id, name, created by, creation time, etc.), but I do not know how to search for the reports' folder paths.
There are command-line tools that call the SAS Viya REST APIs, but what I have seen so far is based in other programming languages (e.g. https://developer.sas.com/apis/rest/ and https://github.com/sassoftware/pyviyatools) and it is not clear how to map those codes into a SAS program.
proc http
url=" http://sasviya35.example.local/reports/reports "
method="get"
oauth_bearer=sas_services
out=jsonout;
run;
libname reports json fileref=jsonout;
proc print data=reports.items;
run;
it is possible to output some information (id, name, created by, creation time, etc.), but I do not know how to search for the reports' folder paths.
There are command-line tools that call the SAS Viya REST APIs, but what I have seen so far is based in other programming languages (e.g. https://developer.sas.com/apis/rest/ and https://github.com/sassoftware/pyviyatools) and it is not clear how to map those codes into a SAS program.
As an output, I would like to have something as the following example:
Report | Folder |
Report1 | /User/Project/Reports |
Report2 | /User/Project/Reports |
Report3 | /User/MyFolder/Test |
Report4 | /Apps/SAS/Data |
Please, let me know if something is unclear and I will try to better explain.
Thanks,
Jorge
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Have a look here https://developer.sas.com/apis/rest/CoreServices/#get-a-resource-39-s-ancestors to get the folder information of a report
SAS sample code looks like:
proc http
url="&BASE_URI/folders/ancestors?childUri=/reports/reports/72c7e418-cd68-49c7-8f2f-6e9548639821"
method='GET'
oauth_bearer=sas_services
out=resp
;
run;
%put NOTE: resp json pretty print;
%put %sysfunc( jsonpp(resp, log));
libname resp json fileref=resp;
proc copy in=resp out=work;
run;