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

Greetings,

 

First off kindly point me to an existing topic in the community if the subject has already been discussed, but from what i searched so far did not find one (maybe i missed it).

Closest i found is:

https://communities.sas.com/t5/SAS-Programming/Can-we-execute-a-job-flow-through-API/m-p/917349/thre...

 

Product: SAS Studio Engineer / Version : 2024.03

Context: i have a job flow in Environment Manager which consists in Flows (.flw) from SAS Studio deployed as jobs (all of them used here in the flow) and some Logic Gates. See Below.

 

Job Flow Name : JF_RUN

ZOR_AD_0-1746517545507.png

 


Now, this Job Flow is scheduled to run daily at 12:00 pm. In case the Job Flow fails with an error, the person responsible with the process will investigate, take necessary measures, and need to execute the Flow again. 

BUT,  Job Flow 2, one of the flows from SAS studio used in this flow in Environment Manager,  works with some input parameters, and, from the investigations made, it turns out that some of them need to be altered, only for the next run iteration. Since the parameters are read from csv's on the server and loaded into tables, we would like to avoid user interaction with the CSV, especially since the parameters modification is only for next execution.

And so we considered generating a Job->Task Prompt from SAS Studio where the user will input parameters (into an XML form) with altered values for Job Flow 2 and then trigger the existing Job Flow in Environment Manager.

 

The question : How can i trigger the execution of my flow JF_RUN in Environment Manager from the Program Tab using SAS code in a Task Prompt, ?

 

ZOR_AD_1-1746517545653.png

 

 

Thank you in advance.

 

Regards,

Alex.

1 ACCEPTED SOLUTION

Accepted Solutions
ZOR_AD
Fluorite | Level 6

Good day sir,

 

First off, you need the job request id from Environment Manager.

ZOR_AD_0-1748877882852.png

 

In the Task Prompt/Program section you use the following:


filename jobresp temp;

 

%let viyaHost = %sysfunc(getoption(SERVICESBASEURL));

 

proc http
url="&viyahost./jobExecution/jobRequests/e703d46b-7798-4c81-9fee-fe18f72b31db/jobs"
method="POST"
out=jobresp
oauth_bearer = sas_services;
run;

 

/*you can assign a lib to see the API response if you run all the above as a program, maybe as a test before prod */
libname jobresp json fileref=jobresp;

Hope this helps!
Best.

View solution in original post

3 REPLIES 3
ZOR_AD
Fluorite | Level 6

Good day sir,

 

First off, you need the job request id from Environment Manager.

ZOR_AD_0-1748877882852.png

 

In the Task Prompt/Program section you use the following:


filename jobresp temp;

 

%let viyaHost = %sysfunc(getoption(SERVICESBASEURL));

 

proc http
url="&viyahost./jobExecution/jobRequests/e703d46b-7798-4c81-9fee-fe18f72b31db/jobs"
method="POST"
out=jobresp
oauth_bearer = sas_services;
run;

 

/*you can assign a lib to see the API response if you run all the above as a program, maybe as a test before prod */
libname jobresp json fileref=jobresp;

Hope this helps!
Best.

ZOR_AD
Fluorite | Level 6

OMG this was EXACTLY what i was looking for! Thank you so much !

 

award.jpg

 

Regards.

ZOR_AD
Fluorite | Level 6

LE: The solution works for the execution of Jobs in Environment Manager.

ZOR_AD_0-1748880777635.png

 

Similar, for the programmatic execution of Job Flows you need to access the specific API and obtain the Flow ID. One option ( that i found so far) is to manually get the Flow ID, meaning:

 

%let viyaHost = %sysfunc(getoption(SERVICESBASEURL));

 

 Go to url: &viyahost./jobFlowScheduling/flows/

 

Scroll, if you haven't filtered in the URL, and find the name of your flow in Environment Manager. EG:

 

Mine is named "JF_API" (very clever, duuh) 

ZOR_AD_1-1748881057969.png

 

So i get the ID from the URL.

 

 {
      "creationTimeStamp": "2025-06-02T15:56:28.497377Z",
      "createdBy": "sasuser",
      "modifiedTimeStamp": "2025-06-02T15:56:28.497378Z",
      "modifiedBy": "sasuser",
      "version": 1,
      "id": "fa3202f7-342d-4a5b-b9cf-85f628d59477",
      "name": "JF_API",
      "links": [

And with the PATCH method (that you also see in the "links" when accessing the Flow API - above) you execute the Job Flow:


filename jobresp temp;

 

%let viyaHost = %sysfunc(getoption(SERVICESBASEURL));

 

proc http
url="&viyahost./jobFlowScheduling/flows/fa3202f7-342d-4a5b-b9cf-85f628d59477/scheduled"
method="PATCH"
out=jobresp
oauth_bearer = sas_services;
run;

 

/*you can assign a lib to see the API response if you run all the above as a program, maybe as a test before prod */
libname jobresp json fileref=jobresp;

 

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 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1049 views
  • 0 likes
  • 1 in conversation