Hello there Community, We are working with the SAS Viya 3.5 Job Execution REST API, and we are trying to find a way to receive the job output directly in the initial POST response, without needing extra requests. Our goal is to trigger a job using the POST /jobExecution/jobs endpoint and, if the job completes, receive the output (such as a JSON result) directly in the same response. However, the current behavior requires a three-step process: POST to /jobExecution/jobs This starts the job, but the response only includes metadata like job ID and state. GET /jobExecution/jobs/{id} We use this to check if the job has finished. GET /jobExecution/jobs/{id}/results If the job is complete, this call returns the final output (for example, a JSON file written by the job). We are looking for a way to reduce this flow and ideally receive the output directly from the POST call, at least when the job is quick and lightweight. Here is an example of the output we expect: {
"SASJSONExport": "1.0 PRETTY",
"SASTableData+hello": [
{
"hello": "Hello World"
}
]
} Currently, we are triggering the job using a simple POST request with a minimal body like this: {
"jobDefinitionUri": "/jobDefinitions/definitions/<job-id>",
"arguments": {
"_contextName": "SAS Job Execution compute context",
"_action": "execute",
"hello": "Hello World"
}
} This works, but the response does not include the job output. We need to check the job status and then call another endpoint to retrieve the result. In the near future, we plan to evolve this into a more structured API integration, where we expect to receive input via a POST request body. That input will likely contain more than 10 fields, similar to the example below: {
"jobDefinitionUri": "/jobDefinitions/definitions/<job-id>",
"arguments": {
"_contextName": "SAS Job Execution compute context",
"_action": "execute",
"hello": "Hello World",
"param1": "value1",
"param2": "value2",
"...": "...",
"param10": "value10"
}
} This is not implemented yet, but it reflects the planned design for our integration. Since we will be sending many parameters, using GET asynchronously with query strings will not be sufficient or maintainable. That’s why we are focusing on solving this via POST requests with a JSON body. We are using the following SAS code in the job: %let hello = &hello;
%let file_uuid = %sysfunc(uuidgen());
filename myjson filesrvc
folderpath="/Users/frm3/My Folder"
filename="export_data_&file_uuid..json";
proc delete data=libname.hello; run;
data libname.hello;
length hello $50;
hello = "&hello.";
run;
proc json out=myjson pretty;
export libname.hello;
run; This code creates a simple dataset with the input parameter and writes it to a JSON file using PROC JSON. Our goal is to access this JSON output directly through the API in a synchronous way. We followed the documentation here: https://developer.sas.com/rest-apis/jobExecution What I am asking is: Is there any way to retrieve job output synchronously using the Job Execution REST API? Any workaround or best practice to make this process more efficient for short-lived jobs? Are there any options to get both synchronous behavior and support for multiple input parameters in the POST body? Any help or suggestions would be greatly appreciated. Thanks,
... View more