Webservice Before Operation rule returns empty json body for requestEndPoint.getBody()

I want to get the body and change the payload before calling create account http operation. But I’m getting null Json body for requestEndPoint.getBody().

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.HashMap;
import org.json.JSONObject;
import connector.common.JsonUtil;
import connector.common.Util;
import sailpoint.tools.GeneralException;
import sailpoint.connector.webservices.EndPoint;
import sailpoint.connector.webservices.WebServicesClient;
import sailpoint.object.Application;
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.AccountRequest;
String logPrefix = “Eagle-Rules”

try{
log.info(logPrefix + “After try block”);
Map body = requestEndPoint.getBody();
String jsonBody = (String) body.get(“jsonBody”);
log.info(logPrefix + "body: " + jsonBody);
log.debug(logPrefix + "body: " + jsonBody);
List jsonList = JsonUtil.toList(jsonBody);
if (jsonList != null && jsonList.size() > 0){
Map roleRequest = (Map) jsonList.get(0);
String uid = roleRequest.get(“uid”);
String firstName = roleRequest.get(“firstName”);
String lastName = roleRequest.get(“lastName”);
String roles = roleRequest.get(“roles”);
String ibus = roleRequest.get(“ibus”);
String pid = roleRequest.get(“pid”);
String lastLogin = roleRequest.get(“lastLogin”);
String isActive = roleRequest.get(“isActive”);
String managerUID = roleRequest.get(“managerUID”);
}

// Put everything back together and set the body

log.info(logPrefix + "roles: " + roles);
log.debug(logPrefix + "roles: " + roles);

} catch (Exception ex) {
log.info(logPrefix + "Rule - Modify Body: " + ex);
}

return requestEndPoint;​

getBody() returns a Map. You need to then get the specific body data from it by type i.e. requestBody.get("jsonBody")

It is still coming as null.

this is my payload :
{
“uid”: “$plan.nativeIdentity$”,
“firstName”: “$plan.firstName$”,
“lastName”: “$plan.lastName$”,
“ibus”: [ “ADM” ],
“roles”: [ “$plan.roles$” ],
“pid”: true,
“lastLogin”: “$plan.lastLogin$”,
“isActive”: true,
“managerUID”: “”
}

So I tried to print requestendpoint object and this is what I got .

EndPoint [_afterRule=null, _beforeRule=Eagle - WebServiceBeforeOperationRule, _contextUrl=/CreateEagleUser, _fullUrl=https://pricing-bid.nonprod.jbhunt.com/pricing-user-management/UserManagement/CreateEagleUser, _httpMethodType=POST, _operationType=Create Account, _rootPath=$, _uniqueNameForEndPoint=Create Account, paginationSteps=null, pagingInitialOffset=0, pagingSize=50, _resMappingObj={firstName=firstName, lastName=lastName, uid=uid, ibus=ibus, roles=roles}, _header={Authorization=*****, Content-Type=application/json}, _body={bodyFormat=raw}, _responseCode=[200], _sequenceNumberForEndpoint=3, xpathNamespaces={}, possibleHttpErrors={}].

If you look create account operation in Identitynow:

It is printing only the format and not the body payload.

You’re missing a semicolon after this line:

yeah. I have semicolon in my script. somehow missed while posting it here.

if roles is a multi-valued attribute, you’ll end up with some weirdness there. Try to change that line to:

“roles”: $plan.roles$,

It could be that the JSON is breaking and ISC is “helping” by removing the invalid JSON.

Thankyou!!! It did work removing the bracket.

1 Like