Send Attribute WebServices Connector

Which IIQ version are you inquiring about?

Version 8.4

Share all details related to your problem, including any error messages you may have received.

Hello

I am provisioning to an application called Cority. It requires the employee number every time in the body of the request when an update is sent.

The body of the POST request needs to be formatted in this way. I can’t get the employeeNumber to be sent everytime. I have been trying in the before operation rule below but it doesn’t put the employeeNumber in the right spot.

{
"options": {
        "autoCreatePortalUser": "true",
        "updateExistingRecords": "true",
        "insertBaseTables": "true",
        "forceLookupTableUpdate": "true",
        "disableSegUpdate": "true",
        "dateFormat": "mm/dd/yyyy"
    },
"records": [
{"employeeNumber": "$plan.employeeNumber$",
"firstName": "$plan.firstName$",
"middleName": "$plan.middleName$",
}
]
}

Before operation rule

import connector.common.JsonUtil;
        import java.text.ParseException;
        import java.text.SimpleDateFormat;
        import sailpoint.object.Identity;
        import sailpoint.object.Link;
        import sailpoint.object.Application;
        import sailpoint.object.ProvisioningPlan;
        import sailpoint.object.ProvisioningPlan.AttributeRequest;
        import sailpoint.object.ProvisioningPlan.AccountRequest;



        log.error("xxx Starting Cority before operation rule");
		
		
		
       //gather objects to get cority ID for the endPoint
        Application Cority = context.getObjectByName(Application.class,"Cority");
        myIdentity =  provisioningPlan.getNativeIdentity();   //returns guid string
        Identity identity = null;
        identity = context.getObject(Identity.class,myIdentity);
        Link corityLink = identity.getLink(Cority);
        corityId = corityLink.getAttribute("id");
        empNumber = corityLink.getAttribute("employeeNumber");
		
		Map body = requestEndPoint.getBody();
        String jsonBody = (String) body.get("jsonBody");
        log.debug("Rule - Modify Body: running");
		
		 try {

            Map jsonMap = JsonUtil.toMap(jsonBody);
			if (jsonMap != null) {
			
			// Extract the records 
			List records = (List) jsonMap.get("records");
			log.error("xxx records size " +records.size());

			// Add employeeNumber 
			for(int i = 0; i < records.size(); i++) {
				Map record = (Map) records.get(i);
				log.error("xxx record " + record);
				log.error("xxx records.get " + records.get(i));
				record.put("employeeNumber", empNumber);
                                log.error("xxx record after " + record);
			}
			
		}

 String finalBody = JsonUtil.render(jsonMap);
                body.put("jsonBody", finalBody);
                requestEndPoint.setBody(body);
		
		} catch (Exception ex) {
            log.error("Rule - Cority Before Opertaion Modify Body: " + ex);
        }
		
		
		Map body = requestEndPoint.getBody();
        log.error("xxx map body value is : "+body);

        String jsonBody = (String) body.get("jsonBody");
        log.error("xxx jsonBody value is : "+jsonBody);

        Map jsonMap = JsonUtil.toMap(jsonBody);
        log.error("xxx jsonMap value is:"+jsonMap);
		
		
	


        return requestEndPoint;​

        log.error("Ending before operation rule");

Hi @ralfonse,

Are you trying to put the employeeNumber in before operation rule and then use plan variable to get employeeNumber ?

You can simply modify the request body itself in the before operation rule. Let me know If you need further input.

Thanks

Hi Ashutosh

I am able to get the empNumber from before operation rule. I am not able to set it in the response where it needs to go. It doesn’t need to come from the plan, it just needs to be in the response.

What do you mean by right spot, can you please be more specific about your issue

Is employee number not your native identity here? and you want to pass the employee id in Update operation body?

Hi Rudolf,

As I understand, the employeeNumber might not be varying always and your plan might not continue everytime and hence you are trying to get the value from link and update your body. Is that right?

Also in your statement below, it says to set it in the response, do you mean request body? or response from the API?

“I am able to get the empNumber from before operation rule. I am not able to set it in the response where it needs to go. It doesn’t need to come from the plan, it just needs to be in the response.”

Your code for before operation rule seems okay, can you confirm if you are able to see the update record with employee number in the below line:

log.error("xyz record after " + record);

If the log provides the updated record, the updated map is not added back to the list. Give a try to consider a new updatedRecords list and add the map to the new list. Set the new updated recordsList to jsonMap again before you update it back to requestBody.

Regards,
Uday Kilambi

Hi @ralfonse,

If it is just about response, then you can use after operation rule to modify your response, but ideal case would be to get it from target directly and use response mapping.

I am not sure why you are using Before Operation Rule if the response mapping you need to update?

Let me know if there is anything specific, I am missing in your use-case.

Thanks

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.