Cannot cast arraylist into string during web service account creation

:bangbang: Please be sure you’ve read the docs and API specs before asking for help. Also, please be sure you’ve searched the forum for your answer before you create a new topic.

I have configured a web service source. account schema is setup two multivalued entitlement attributes. (rolenames and permittedSolutionSubTypes). all other attributes non- muti value

when i request access for account create. account gets created in the target system. but event logs and access request page is following error.

[“Exception occurred while performing \u0027Create\u0027 operation on identity \u0027leslie.fisher@parknationalbank.com\u0027: Error: class java.util.ArrayList cannot be cast to class java.lang.String (java.util.ArrayList and java.lang.String are in module java.base of loader \u0027bootstrap\u0027)”]

I even tested create by submitting a request with only one role and one loan and, i validated that attribute request for loan and role attributes are being sent as String.

I will also attach screenshot of json body. if anyone can help me pinpoint the issue that would be greatly appreciated.

note: account gets created in target system. provisioning event shows as failure

Hi @nikeshpark29 ,

In the Schemas, change rolenames and permittedSolutionSubTypes to Array.

  1. In your Create policy’s JSON mapping, reference them without quotes:

    "rolenames": {{rolenames}},
    "permittedSolutionSubTypes": {{permittedSolutionSubTypes}}
    

That way ISC emits real JSON arrays (e.g. ["A","B"]) and avoids the ArrayList→String cast error.

Hello S,

both attributes are set multi-valued and type as their associated entitlements.

for json mapping in the http configuration, i have not used quotation but i would still need to use the $plan place holder right? anything else would cause to invalid json format.

“permittedSolutionSubTypes”: $plan.permittedSolutionSubTypes$,

“roleNames”: $plan.roleNames$,

The best approach is implementing a Web Services Before Operation Rule to convert ArrayList objects to proper JSON arrays before the API call executes.

import java.util.ArrayList;
import java.util.List;
import connector.common.JsonUtil;

Map body = requestEndPoint.getBody();
String jsonBody = (String) body.get("jsonBody");

Map jsonMap = JsonUtil.toMap(jsonBody);

if (jsonMap != null) {
    // Handle roleNames
    Object roleNamesObj = jsonMap.get("roleNames");
    if (roleNamesObj instanceof ArrayList) {
        jsonMap.put("roleNames", (List) roleNamesObj);
    }
    
    // Handle permittedSolutionSubTypes
    Object subTypesObj = jsonMap.get("permittedSolutionSubTypes");
    if (subTypesObj instanceof ArrayList) {
        jsonMap.put("permittedSolutionSubTypes", (List) subTypesObj);
    }
    
    // Render and update body
    String finalBody = JsonUtil.render(jsonMap);
    body.put("jsonBody", finalBody);
    requestEndPoint.setBody(body);
}

return requestEndPoint;


  • Add Web Services before operation rule to Create Account operation using VS Code Extention.

  • The rule converts ArrayList objects to List format that JsonUtil properly serializes to JSON arrays.

    Hope this helps.