Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Pass response from API to second call

PratithShetty
New Contributor III
New Contributor III

Hi All,

Usecase : 

1) Get account details of the user from endpoint 7. 

2) Pass the comments field in the response to the second API call.

3) Second API call updates user profile with the comments value. 

I am using the Sav4Sav Rest connector and below is my UpdateUserJson 

{
"actions": {
"Disable User": {
"call": [
{
"name": "call1",
"callOrder": 0,
"connection": "userAuth",
"url": "https://XXX/ECM/api/v5/getAccounts",
"httpMethod": "POST",
"httpParams": "{\"username\":\"${user.username}\",\"accountQuery\":\"acc.endpointkey='7'\"}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
200
]
}
},
{
"name": "call2",
"callOrder": 1,
"connection": "userAuth",
"url": "https://XXX/ECM/api/v5/updateUser",
"httpMethod": "POST",
"httpContentType": "application/json",
"httpParams": "{\"username\":\"${user.username}\",\"customproperty44\":\"${response.call1.message.Accountdetails[0].comments}\"}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"successResponses": {
"statusCode": [
200,
201
]
}
}
]
}
}
}

Here is the response from the firstcall 

{
"msg": "Successful",
"displaycount": 1,
"total": 1,
"Accountdetails": [
{
"creator": "System created",
"comments": "ServiceNow Request Number=REQ0021701",
"displayName": "000324794",
"endpointKey": 7,
"createdon": "07/27/2024",
"userKey": "23194",
"accountKey": 798568,
"accountID": "000324794",
"endpoint": "AD Snow Form",
"updatedate": "07/27/2024",
"accountowner": [],
"name": "000324794",
"status": "Manually Provisioned",
"username": "000324794"
}
],
"errorCode": "0"
}

ErrorTask Response: {"Disable User":{"headers":null,"message":{"errorCode":"1","message":" Users not found with username ${users.username}"},"statusCode":412,"description":null,"status":"Failed"}}

The issue is with the response.call1.message.Accountdetails[0].comments beacuse the above JSON works with the customproperty44 is hardcoded. Can anyone please help here? 

3 REPLIES 3

NM
Honored Contributor III
Honored Contributor III

Hi @PratithShetty , instead of users.username use user.username

if this doesn't work, trigger the job, fetch the logs and share it across


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

PratithShetty
New Contributor III
New Contributor III

@NM  - Did, the same issue persists. 

rushikeshvartak
All-Star
All-Star
  • Share full logs

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.