Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Dependent Multiple calls in ImportUserJSON - REST Connector

ashutoshkumar16
New Contributor II
New Contributor II

Hi Experts,

We are integrating a HR source to Saviynt which is of connection type REST.

We have to do 2 API calls to get all the user data. The first call returns the user's detail and the 2nd call returns the user's position detail. and 2nd call is dependent on 1st call as we need to pass a positionid from the 1st call to the 2nd call in the URL.

Example :

url1 :  https://test-test/tt/employees

Response Sample: [

{

  "userid" : "23423"

  "first_name": "Jhon",

  "position": {

     "position_id": "25OK"

   }

}

]

We have to use position_id of the user to make a 2nd call and map the attribute. position_id is used in the URL 

url2 call example: https://test-test/tt/postion/<position_id>

We are looking for a solution for dependent multiple calls in importuserjson in Rest Connector.

Please Suggest.

 

15 REPLIES 15

naveenss
All-Star
All-Star

Hi @ashutoshkumar16 ,

Please refer to the below REST connector developer handbook to use the multiple API call usage. 

naveenss_0-1688115444868.png

https://docs.saviyntcloud.com/bundle/REST-v23x/page/Content/Developers-Handbook.htm

Let me know in case of any questions.

 

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

@naveenss , thanks for your reply, but in the Screenshot, its for the Account import(ImportAccountJSON)  and we are looking for User Import (ImportUserJSON) for which Saviynt have not mention how to handle dependent call in User Import.

Will that json example work in ImportUserJSON?

mbinsale
Saviynt Employee
Saviynt Employee

It is basically the same. It will work for ImportUserJSON too

I am using the dependent call vairable in my JSON but seems it not working.

I am using username as a binding variable from the first call and get the user metadata in second call.

I am mapping Postition_id to customproperty15 in the first call and trying to get the the value in URL of the second call.

"url": "https://XXXXXX/hr-wfm/api/v1/positions/${customproperty15}"

"inputParams": {
"dependentCall": true
},
"nextApiKeyField": "username",

But below error:

DEBUG rest.RestProvisioningService - Error while getting User Import response for url- https://XXXXXXXX/api/v1/positions/${customproperty15} is: null\n","stream":"stdout","time":"2023-07-09T06:31:04.309818527Z"}


rest.RestProvisioningService - Got Webservice API Response: [error:Error Illegal character in path at index 66: https://XXXXXXXX/api/v1/positions/${customproperty15}]\n","stream":"stdout","time":"2023-07-09T06:31...

 

I have attatched full ImportUserJSON for your reference.

Can you remove the below from your JSON and then try. 

"type": "multiCall",


Regards,
Sahil

ashutoshkumar16
New Contributor II
New Contributor II

When I removed the type from JSON, I am getting a different error below:

Cannot invoke method containsKey() on null object

Ambiguous method overloading for method java.lang.String#. Cannot resolve which method to invoke for [null] due to overlapping prototypes between: [class [B] [class [C] [class java.lang.String]

Can you try with the below JSON instead. Also just to confirm, is the value getting saved for the users in CP15 even if the call2 fails?

{
"type": "multiCall",
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "https://XXXXX/hr/hr-wfm/api/v1/employees?limit=2",
"httpMethod": "GET",
"httpHeaders": {
"app_key": "<APP_KEY>",
"Authorization": "${access_token}"
},
"colsToPropsMap": {
"username":"payroll_id~#~char",
"systemUserName":"payroll_id~#~char",
"firstName":"first_name~#~char",
"lastName":"surname~#~char",
"customproperty15":"occupancy[0].position.position_id~#~char"
},
"userResponsePath": "employees"
},
{
"name": "call2",
"connection": "userAuth",
"url": "https://XXXXXX/hr-wfm/api/v1/positions/${customproperty15}",
"httpMethod": "GET",
"httpHeaders": {
"app_key": "<APP_KEY>",
"Authorization": "${access_token}"
},
"colsToPropsMap": {
"username": "assigned_to.value~#~char",
"CUSTOMPROPERTY16": "position_title~#~char"
},
"userResponsePath": ""
}
]
}

Regards,
Sahil

ashutoshkumar16
New Contributor II
New Contributor II

Still the same error. And CP15 value is being saved correctly

DEBUG rest.RestProvisioningService - Calling Webservice Url - https://XXXXX/hr/hr-wfm/api/v1/positions/${customproperty15} with httpParams - null\n","stream":"stdout","time":"2023-07-11T16:28:36.727324187Z"}

I can see the userIdentifierValue being set in the first call  but it is unable to resolve CP15 value from the first call in second call URL.

DEBUG rest.RestProvisioningService - userIdentifierValue: 00061\n","stream":"stdout","time":"2023-07-11T16:28:36.758464113Z"} 

Is it possible to add payroll_id (username) in call2 instead of customproperty15 to fetch the attributes you need from 2nd call. Or in case there is any other url where we can use payroll_id  (username value in Saviynt) to get the data you need.

Also please confirm if the 2nd call that you are currently using, is it a user specific call and a separate call will be sent for each user.


Regards,
Sahil

ashutoshkumar16
New Contributor II
New Contributor II

There is no such api avaliable where we can use payroll_id to fetch the position detail of the user.

And yes, this is user specific call and will be sent for each user, we have run 2nd call for each and every user, using position_id that we get in the first call, to get the position details although its a postion specific call that we have to map in the user attribute.

 

SB
Saviynt Employee
Saviynt Employee

Can you make the below changes and then try.

1. Update colsToPropsMap of call 1 and define customproperty15 at the very beginning

"colsToPropsMap": {
"customproperty15":"occupancy[0].position.position_id~#~char",
"username":"payroll_id~#~char",
"systemUserName":"payroll_id~#~char",
"firstName":"first_name~#~char",
"lastName":"surname~#~char"}

2. Update the url for 2nd call as 

"url": "https://XXXXXX/hr-wfm/api/v1/positions/${userIdentifier}"

Note: The binding variable will always be ${userIdentifier} in the successive call and it will pick the value from first attribute mapping mentioned in the colsToPropsMap of the previous call. 


Regards,
Sahil

ashutoshkumar16
New Contributor II
New Contributor II

Hi Sahil,

It worked  but the 2nd call doesn't contain the username(payroll_id) in its response so if we do not map the username in colsToPropsMap it creates a new user in the 2nd call.

we have tried to map username using dependent call variable but its returning null. 

colsToPropsMap:

"inputParams": {
"dependentCall": true
},
"nextApiKeyField": "username",
"colsToPropsMap": {
"username": "assigned_to.value~#~char",
"CUSTOMPROPERTY16": "position_title~#~char"
},

we also tried ${username} in the colsToPropsMap but its also returing null.

How to map user attribute in the second call for the user created in the first call as I am not able get the usename.

SB
Saviynt Employee
Saviynt Employee

Since you are using username as your recon filed, it has to be present in your 2nd call too for the application to identify whether a record exists or not. Alternatively, you can try to see if there is any other unique identifier that is returned in both your calls and can be used as a recon field.


Regards,
Sahil

ashutoshkumar16
New Contributor II
New Contributor II

Recon field, Username is not in the response of 2nd call and there is no unique identiter that is returned in both the calls.

is there a way we can get the username(payroll_id) of the user from the 1st call in the 2nd call for the user 2nd call is being called for ?

This identifier value has to be part of your 2nd call response itself and will be sent by target application.


Regards,
Sahil