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

Custom Jar to update user in user update rule

Regular Contributor II
Regular Contributor II

Hello Team,


I am using custom JAR to update user on specific action, JAR is getting triggered properly. Now I have updated the JSON using JSONObject and when I printed in the logs then its showing the proper updated JSON, same JSON I am returning but the user not getting updated.

I have used following code :

public String updateUser(String userJson) throws JSONException {

JSONObject json = new JSONObject(userJson);
String response=null;

try {"*********************INPUT JSON***********************");"INPUT "+json);"*********************ENDED***********************");

json.put("customproperty43", "THISISREHIRECASE");

catch(Exception e) {"Exception occurred "+e);
return response;



With this, NO error but user not getting updated, what is proper method to update from JAR?


Also I tried using POJO class, where I have defined user attributes,setter and getter in and one response class where I am setting user object. I am using below custom method

Gson gson = new Gson();
JsonObject obj = new JsonParser().parse(userJson).getAsJsonObject();"*********************INPUT DATA***********************");"Input DATA is "+obj);"*********************CLOSED***********************"); User
userData =gson.fromJson(obj, User.class);   //here getting the error
//(User)gson.fromJson(userJson, User.class);"*********************FINAL DATA***********************");"Input userDATA is "+userData);"*********************CLOSED***********************");
userData.setCustomproperty41("ThisIsRehireCase");"Set the CP41"); 
response.setUsers(userData);"Set the user data");"EXITING....."+methodName+" "+CLASS_NAME);


With this, I am getting below error :

Exception occurred java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT

Please help.





Saviynt Employee
Saviynt Employee

Hi @rahul_p ,

         The Custom action doesn't have and accept any return object. In jar as only input paramter you will get all user related attributes. If you want to perform any action that needs to be handled in Jar itself.  As a highlevel example if you want to update any saviynt object use saviynt rest api in jar.

By seeing the code I can understand that your trying to update CP43 of user for that in custom jar you have use  "{{url}}/ECM/{{path}}/updateUser" rest api. But that can be easily achieved by update user json by mapping the saviynt connection.

This action is introduced to provide fessibility to use in case of any action that can't be achieved by OOTB.





Hi Kishore,

Do you have an explanation for the error message Exception occurred java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT? We are also running the custom jar current on this error.

We only want to read out the user data.

public void customSAPWriteBack(String userJson) throws JCoException {
              System.out.println("userJson data : " + userJson);
             GsonBuilder builder = new GsonBuilder();
             Gson gson = builder.create();
               User userData = (User)gson.fromJson(userJson, User.class);

This worked fine in a previous Saviynt version. Now - with 23.7 - we get this exception as soon as we try to read the JSON object passed to the method.

Must something be adapted in the coding here now with the newer Saviynt version??

Grateful for any idea.