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

Hi guys,

 

I need your help. I created with SAS Studio a job execution code and it runs correctly when I launch it from https://myserver/SASJobExecution/....

The submit link runs whenever I call the job in the open website but every time I use postman to launch the code with the defition url (taken from the job I created) it doesn't work. I have all the tokens that the request needs and I receive a 201 positive response but when I try to get the state it returns always failed.

The error is this:

 

prova.pngCan someone help me please?

Maybe some parameters from management environment are set wrong? 

@joeFurbee 

1 ACCEPTED SOLUTION

Accepted Solutions
joeFurbee
Community Manager

Hi @MatteBalda981,

It could be a number of things on the compute/context side. I'm afraid though that since we can't reproduce the issue from our side, you may need to log a ticket with tech support. There may be local compute and context configurations that we can't troubleshoot here.

 

Please make sure you refer to this thread with tech support, so they can review the history of what we've tried so far.


Join us for SAS Community Trivia
SAS Bowl XLVI, Causal Analysis
Wednesday, December 18, 2024, at 10 a.m. ET | #SASBowl

View solution in original post

12 REPLIES 12
joeFurbee
Community Manager

Hi @MatteBalda981,

Here is a link to a postman collection in our SAS Viya REST API end-to-end repository. I've linked the Postman specific use case for JobExecution. Can you compare the call I have there vs what you have in Postman?

 

The call I have for the job execution in the collection is:

{{sasserver}}/jobExecution/jobs

as defined in our API doc.

 

I assume you're using the same token in both cases (Studio vs Postman), or are you creating the token used for the Postman calls in Postman?


Join us for SAS Community Trivia
SAS Bowl XLVI, Causal Analysis
Wednesday, December 18, 2024, at 10 a.m. ET | #SASBowl

MatteBalda981
Fluorite | Level 6

Hi @joeFurbee ,

 

Thank you for your support. I'm using the same call available in your postman collection and the bearer token is the same in Studio and postman.

 

Is there any additional setting (e.g. _contextName) that could impact on the procedure?

 

Thank you again

joeFurbee
Community Manager

Hi @MatteBalda981,

The _contextName should be picked up by default in this call I believe.

In Postman, there is a </> icon on the right-hand side. You can choose the format of the call at the top. Choose cURL. Can you forward me the call (removing any sensitive data)? If you don't want to post the call here, feel free to private message me here in Communities or send me an email: joe.furbee@sas.com.

 

Also, have you tried to run the command via cURL?

 

 


Join us for SAS Community Trivia
SAS Bowl XLVI, Causal Analysis
Wednesday, December 18, 2024, at 10 a.m. ET | #SASBowl

MatteBalda981
Fluorite | Level 6

Hi @joeFurbee ,

 

Thanks! Yes, I tried to run with cURL but the error is the same. 

Here you are what you have asked (I removed the sensitive data😞

 

curl --location --request POST 'myserver/jobExecution/jobs' \
--header 'Authorization: Bearer 123456789' \
--header 'Content-Type: application/json' \
--data-raw '{
  "name": "Hello World Execution",
  "description": "Execution of the job we previously created",
  "jobDefinitionUri": "/jobDefinitions/definitions/111111-222222-3333333-5555555"
}'

I really don't understand why from postman job doesn't run 😞 

Thanks again

joeFurbee
Community Manager

Hi @MatteBalda981,

I'm stumped as well. From the code block I got from Postman, I replaced '--location --request', with '-k -X', but I don't think that has anything to do with getting 'Access denied'.

 

Are you able to run other requests using this token? Say the Folders API? Something like:

--header 'Accept: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImprdSI.....' 
 
Or any other API calls you can try around Jobs. Maybe get a list of jobs with:
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImprdSI.....' 

Join us for SAS Community Trivia
SAS Bowl XLVI, Causal Analysis
Wednesday, December 18, 2024, at 10 a.m. ET | #SASBowl

BrunoMueller
SAS Super FREQ

A state of failed can also mean, there was an error while running the code. Have you tried to read the log from the executed job?

Do a GET on {{viya_base_url}}/jobExecution/jobs/0e355cd4-7050-418c-8859-71bafc378442 the exact URL you get from the response when executing the job defintion

You will then find in the returned JSON the "results" use the "...log.txt" url like so:

GET {{viya_base_url}}/files/files/043c0310-0615-4af5-9705-5b4ab06702f4/content

This should give you plain text SAS log.

 

Maybe this will help with finding what is wrong.

MatteBalda981
Fluorite | Level 6

Hi @BrunoMueller @joeFurbee ,

 

It seems that the only way to run correctly the job is starting a session through {{myaddress}}/compute/sessions and then including the session id into job execution body request ({{myaddress}}/jobExecution/jobs).

 

e.g.:

{

  "name": "AAAAAA",

  "description": "Execution of the job",

  "jobDefinitionUri": "/jobDefinitions/definitions/aaa11bb22-............",

  "arguments":{

    "_contextName": "SAS Job Execution compute context",

    "_sessionId": "1111aaaa-2222bbb....."

  }

}

Finally, we are able to obtain the link to the log and we can notice that the autoexec (included into the SAS Job Execution compute context in the SAS environment manager) job is not executed.

 

If we don't follow these steps, we are not able to obtain the log into the returned Json and the result is the following:

               

                                                              MatteBalda981_0-1668616076120.png

 

Should we start a new session every time we need to run the job (otherwise SAS is not able to start it by itself)?

There is a way to include the run of autoexec into the request?

 

Thank you again for your support!

joeFurbee
Community Manager

Hi @MatteBalda981,

I checked with my good friend and job execution SME @Mike_Drutar. He dug through some of his work and in a Python code snippet he did have the context name included in his body text, but no session id. Moreover, he had different headers. I did not include content type and accept headers in my Postman calls. I took a look a the doc and I see the following example for curl:

curl -X POST https://example.com/jobExecution/jobs \
  -H 'Authorization: Bearer <access-token-goes-here>' \
  -H 'Content-Type: application/vnd.sas.job.execution.job.request+json' \
  -H 'Accept: application/vnd.sas.job.execution.job+json'

Can you please try with the new headers and just the _contextName and see if that's successful? It would be good if it works with just the context name and not the session id. The former is known and can easily be included in your body text. The latter must be derived and placed there.


Join us for SAS Community Trivia
SAS Bowl XLVI, Causal Analysis
Wednesday, December 18, 2024, at 10 a.m. ET | #SASBowl

MatteBalda981
Fluorite | Level 6

Hi @joeFurbee ,

thanks for your quickly answer.

 

Unlucky it doesn't work and the error is always the same. We really think that there is a problem with the compute context. We have tried to launch a post request to the compute server from job execution id to create a session. The error is in the image below and it is the same of the job execution.

 

error.png

 

What does it means? 

Could we have some error in the environment configuration?

Is there any link between the two similar errors?

 

Thanks as always.

MatteBalda981
Fluorite | Level 6

Hi @joeFurbee ,

 

Another idea is that we haven't a compute service account able to launch the launcher server. Is maybe this the real problem for all the errors?

 

Thanks.

joeFurbee
Community Manager

Hi @MatteBalda981,

It could be a number of things on the compute/context side. I'm afraid though that since we can't reproduce the issue from our side, you may need to log a ticket with tech support. There may be local compute and context configurations that we can't troubleshoot here.

 

Please make sure you refer to this thread with tech support, so they can review the history of what we've tried so far.


Join us for SAS Community Trivia
SAS Bowl XLVI, Causal Analysis
Wednesday, December 18, 2024, at 10 a.m. ET | #SASBowl

MatteBalda981
Fluorite | Level 6

Hi @joeFurbee @BrunoMueller ,

 

I write here for a similar problem. Now we have resolved the job execution with sas support and the requests go successfully but I have another question. In these days I am starting to make a lot of request in sas server (for write json file) similar to this:

 

curl --location --request POST 'https://server:port/files/files?parentFolderUri=/folders/folders/544343243ed' \
--header 'Content-Disposition: form-data; name="file"; filename="Score_Request_Imprese.json"' \
--header 'Authorization: Bearer .....' \
--header 'Content-Type: application/json' \
--data-raw '{
  "input_file": [
    {
      
    }
  ]
}
'

I would like to see the log of the request from sas server but I dont' find it. Where Can I see it? For example if i receive an 400:bad request error in the request in which path (from server connection) can I see the log or the server answer?

 

Thanks Again,

Matteo

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 12 replies
  • 6928 views
  • 1 like
  • 3 in conversation