In the Create report document there is an example of creation VA report. I tested this piece of code and the creation of the report is not complete. I can’t open the report created by this code in SAS VA(so I can’t apply modifications using Ctrl+Alt+B XML code or any other way).
My questions are:
%let folder_uri=/folders/folders/6bcef06c-554c-4ac8-8790-d921977f9933;
%let BASE_URI=%sysfunc(getoption(servicesbaseurl));
filename rep_id temp;
filename body_in temp;
data _null_;
file body_in;
put '{ "name": "test_report",';
put '"description": "testdescription"}';
run;
proc http url="&BASE_URI.reports/reports?parentFolderUri=&folder_uri"
method='post'
oauth_bearer=sas_services
in = body_in
out=rep_id;
headers "Content-Type"="application/vnd.sas.report+json"
"Accept"="application/vnd.sas.report+json";
run;
Hi @idziemianczyk,
My colleague @CindyWong attempted to reply to your inquiry, but experienced technical issues. She forwarded me her response in the meantime and I'll place it below.
/* retrieve the report content object from an existing report */
%let BASE_URI=%sysfunc(getoption(SERVICESBASEURL));
FILENAME rContent TEMP ENCODING='UTF-8';
PROC HTTP METHOD="GET" oauth_bearer=sas_services OUT= rContent
URL = "&BASE_URI/reports/reports/ffb113b7-9cfa-434b-99f1-9b3fe5a9f340/content";
HEADERS "Accept" = "application/vnd.sas.report.content+json";
RUN;
/* create a new report object in a folder */
FILENAME tReport TEMP ENCODING='UTF-8';
FILENAME hdrout TEMP ENCODING='UTF-8';
PROC HTTP METHOD = "POST"
URL = "&BASE_URI/reports/reports?parentFolderUri=/folders/folders/dbbc365c-69dc-4e3f-97c9-49818029fde1"
OUT = tReport HEADEROUT=hdrout
OAUTH_BEARER = SAS_SERVICES
IN = '{
"name": "Report by API",
"description": "Create Report from REST API"
}' ;
HEADERS "Accept" = "application/vnd.sas.report+json"
"Content-Type" = "application/vnd.sas.report+json" ;
RUN;
/* print the response header, and get the value of 'ETag' and 'Last-Modified' */
data _null_;
infile hdrout;
input;
put _infile_;
run;
/* save the retrieved report content object to the newly created report */
/* need to replace the IF-MATCH value with the value of ‘ETag’ from previous response header */
/* need to replace the IF-UNMODIFIED-SINCE value with the value of ‘Last-Modified’ from previous response header */
PROC HTTP METHOD = "PUT"
URL = "&BASE_URI.&rptid/content"
OAUTH_BEARER = SAS_SERVICES
IN = rContent ;
HEADERS "Accept" = "*/*"
"Content-Type" = "application/vnd.sas.report.content+json"
"IF-MATCH" = """kjv0va4n"""
"IF-UNMODIFIED-SINCE" = "Wed, 13 Jan 2021 06:07:37 GMT"
;
RUN;
/* Now you should be able to open the new report in VA */
Join us for SAS Community Trivia
SAS Bowl XXXVI, Data Simulation
Wednesday, December 13, 2023, at 10 a.m. ET | #SASBowl
Hi @idziemianczyk,
My colleague @CindyWong attempted to reply to your inquiry, but experienced technical issues. She forwarded me her response in the meantime and I'll place it below.
/* retrieve the report content object from an existing report */
%let BASE_URI=%sysfunc(getoption(SERVICESBASEURL));
FILENAME rContent TEMP ENCODING='UTF-8';
PROC HTTP METHOD="GET" oauth_bearer=sas_services OUT= rContent
URL = "&BASE_URI/reports/reports/ffb113b7-9cfa-434b-99f1-9b3fe5a9f340/content";
HEADERS "Accept" = "application/vnd.sas.report.content+json";
RUN;
/* create a new report object in a folder */
FILENAME tReport TEMP ENCODING='UTF-8';
FILENAME hdrout TEMP ENCODING='UTF-8';
PROC HTTP METHOD = "POST"
URL = "&BASE_URI/reports/reports?parentFolderUri=/folders/folders/dbbc365c-69dc-4e3f-97c9-49818029fde1"
OUT = tReport HEADEROUT=hdrout
OAUTH_BEARER = SAS_SERVICES
IN = '{
"name": "Report by API",
"description": "Create Report from REST API"
}' ;
HEADERS "Accept" = "application/vnd.sas.report+json"
"Content-Type" = "application/vnd.sas.report+json" ;
RUN;
/* print the response header, and get the value of 'ETag' and 'Last-Modified' */
data _null_;
infile hdrout;
input;
put _infile_;
run;
/* save the retrieved report content object to the newly created report */
/* need to replace the IF-MATCH value with the value of ‘ETag’ from previous response header */
/* need to replace the IF-UNMODIFIED-SINCE value with the value of ‘Last-Modified’ from previous response header */
PROC HTTP METHOD = "PUT"
URL = "&BASE_URI.&rptid/content"
OAUTH_BEARER = SAS_SERVICES
IN = rContent ;
HEADERS "Accept" = "*/*"
"Content-Type" = "application/vnd.sas.report.content+json"
"IF-MATCH" = """kjv0va4n"""
"IF-UNMODIFIED-SINCE" = "Wed, 13 Jan 2021 06:07:37 GMT"
;
RUN;
/* Now you should be able to open the new report in VA */
Join us for SAS Community Trivia
SAS Bowl XXXVI, Data Simulation
Wednesday, December 13, 2023, at 10 a.m. ET | #SASBowl
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.
Find more tutorials on the SAS Users YouTube channel.