Announcing the SAVIYNT KNOWLEDGE EXCHANGE unifying the Saviynt forums, documentation, training, and more in a single search tool across platforms. Click HERE to read the Announcement.

Rest API error handling powershell script

Ankyt19
Regular Contributor
Regular Contributor

Hi Team,

we are using rest API connection, which is triggering powershell script in remote server . Everything is working fine when successful . Let’s say when powershell script is triggered , As per Saviynt , it has called the script and gets success msg . After going to powershell script , if for some reason it didn’t execute the task , how can Saviynt keep the task in pending only ? 

please send sample script for such error handling if anyone has it ? 

thanks

ankit 

11 REPLIES 11

Hi @Ankyt19,

When does Saviynt close out the task successfully ? How does Saviynt know when to keep the task open and when to keep it in a pending state ? When it recieves a response from the call right.

You could map the response back in your API call, similar to the snippet shared below based on the response. for e.g.

"SuccessResponses": {"": ["Success"]},
"unsuccessResponses": {"responseMessage": ["\"Failed\"","\"Powershell script taking too long \""]}

 

 

Regards,
Avinash Chhetri

Ankyt19
Regular Contributor
Regular Contributor

Hi @avinashchhetri  ,

I am using below snippet to capture failed message:

"httpContentType": "application/x-www-form-urlencoded",
"successResponses": {
"response[6].Objectreturned": ["Success"]
},
"unsuccessResponses": {
"response[6].Objectreturned": ["Failure"]

 

Just for your info, If it fails to communicate to remote server to execute any tasks, it does remain in pending task with some error .

 

But lets say , If it is able to connect to remote server and executed powershell script, it doesn't show in failed task(pending task) it goes to completed task and unless we go and check in powershell script logs , we will not be able to identify . Hence we would like to know if anyone can help me with some snippet to capture error from Powershell script ?

Thanks

Ankit

@Ankyt19,

What does the response in the logs show when it connects and executes but fails for some reason ?

 

Regards,
Avinash Chhetri

Ankyt19
Regular Contributor
Regular Contributor

@avinashchhetri 

 

{"Objectreturned":"The user is null","Length":"17"} statusCode":200,"description":null,"status":"Success"}}

Ankyt19
Regular Contributor
Regular Contributor

Hi @avinashchhetri  and @rushikeshvartak  and @ashisht  @Harish_Yara @SureshV 

Please suggest if anything on capturing error or string message and add in create account json , so that unsuccess responses will have the task in PENDING instead of completed . 

 

Thanks

Ankit

Harish_Yara
New Contributor III
New Contributor III

Hi all,

Can someone help in fixing this issue? @rushikeshvartak @avinashchhetri

 

Thanks,

Harish

Hi All,

Please suggest to fix the issue stated below.

Issue - New Account pending task is created for REST connector, when an issue occurs pending task is getting completed and task status is showing as complete.

Expectation - When an issue occurs the task should be discontinued or Errored out then move to Completed Task list.

Please suggest what config to add to make this happen?

@rushikeshvartak @Darshanjain @SB @DaanishJawed @Ankyt19  

SB
Saviynt Employee
Saviynt Employee

Can you share Create Account JSON. Also, the logs snippet for the response when you get the error and the task still gets completed.


Regards,
Sahil

Harish_Yara
New Contributor III
New Contributor III

Hi @SB 

Please find Create Account JSON

{
"accountIdPath": "accountName",
"responseColsToPropsMap": {},
"call": [{
"name": "call1",
"connection": "userAuth",
"url": "https:xxxxx",
"httpMethod": "POST",
"httpParams": xxxx
"httpHeaders": {
"Authorization": ""
},
"httpContentType": "application/x-www-form-urlencoded",
"successResponses": {
"response[6].Objectreturned": ["Success"]
},
"unsuccessResponses": {
"responseMessage": [{"Objectreturned":"The user is null"}]
}
}]
}

Note : String The user is null is thrown from Powershell script to Saviynt in Provisioning Comments of Completed Task.

For your reference below is the Log nippet.

Harish_Yara_0-1680714556903.png

Regards,

Harish

 

SB
Saviynt Employee
Saviynt Employee

Can you also share the complete logs with the response included when you get the error


Regards,
Sahil