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

First question: Is it possible to modify job definition with REST API? Can you show an example of code to do it? 

 

I was able to do it with a reports and METHOD="PUT": 

PROC HTTP METHOD="PUT" URL="&BASE_URI./&dstReportURI./content" OAUTH_BEARER=SAS_SERVICES
IN=&contentFile. HEADEROUT=hdrout ;
HEADERS "Accept"="*/*"
"Content-Type"="application/vnd.sas.report.content+json"
"IF-MATCH"=""&ETAG""
"IF-UNMODIFIED-SINCE"=&MODDATE.;
RUN;

 

Second question: How can I extract ETAG from the existing job? I was able to extract headers from the report, but a similar code doesn't return ETAG for jobs.

 

This code returns header info with ETAG for reports:

	PROC HTTP METHOD="HEAD" URL="&BASE_URI&report_uri."
	OUT=rep_id HEADEROUT=hdrout OAUTH_BEARER=SAS_SERVICES;
				HEADERS "Accept"="application/vnd.sas.report+json" 
					"Content-Type"="application/vnd.sas.report+json";
			RUN;

 

This code returns a header content, but with no ETAG for the job:

	PROC HTTP METHOD="HEAD" URL="&BASE_URI/jobDefinitions/definitions/&job_uri
	OUT=rep_id HEADEROUT=hdrout OAUTH_BEARER=SAS_SERVICES;
				HEADERS "Accept"="application/vnd.sas.job.definition+json" 
					"Content-Type"="application/vnd.sas.job.definition+json";
			RUN;

 

At that moment I see 2 milestones:

1. How to extract ETAG from existing job?

2. How to update existing report with new code/parameter?

 

Thanks in advance,

Ivan

 

1 ACCEPTED SOLUTION

Accepted Solutions
joeFurbee
Community Manager

Hi Ivan (@idziemianczyk ),

1. How to extract ETAG from existing job?

I'm not sure why your response does not contain an ETag in the header? I passed an API call for a job definition and I see the ETag header in the response:
getJobDefinition.jpg

2. How to update existing report with new code/parameter?

Take a look at the SAS Viya API documentation. There is a good example of a create job and an update job API call. The example uses similar parameters and code, so you should be able to see the difference in the update call.

 

Please let me know if I can assist further.

 

Thanks,

Joe


Join us for SAS Community Trivia
SAS Bowl XXXVIII, SAS Programming: Getting Started
Wednesday, February 14, 2024, at 10 a.m. ET | #SASBowl

View solution in original post

2 REPLIES 2
joeFurbee
Community Manager

Hi Ivan (@idziemianczyk ),

1. How to extract ETAG from existing job?

I'm not sure why your response does not contain an ETag in the header? I passed an API call for a job definition and I see the ETag header in the response:
getJobDefinition.jpg

2. How to update existing report with new code/parameter?

Take a look at the SAS Viya API documentation. There is a good example of a create job and an update job API call. The example uses similar parameters and code, so you should be able to see the difference in the update call.

 

Please let me know if I can assist further.

 

Thanks,

Joe


Join us for SAS Community Trivia
SAS Bowl XXXVIII, SAS Programming: Getting Started
Wednesday, February 14, 2024, at 10 a.m. ET | #SASBowl

idziemianczyk
Obsidian | Level 7

I missed etag because I read the file in SAS code (hasn't checked the file itself). There was no ETAG.

 

My code for reading a header file was wrong, the line with ETAG wasn't visible. Anyway, the problem solved. Thanks a lot. 

 

idziemianczyk_0-1643727928905.png

idziemianczyk_1-1643728549661.png

 

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

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.

Discussion stats
  • 2 replies
  • 1332 views
  • 1 like
  • 2 in conversation