Handling Null Values for Pronouns in target source HTTP UPDATE Operation

Hi ,

The Pronouns attribute is currently mapped 1:1 in the Identity Profile, with no transformation applied, directly from the source attribute.

The Pronounce attribute is also defined in the target source’s UPDATE HTTP operation as below

{
"OrgDefinedId": "$plan.UserName$",
"FirstName": "$plan.FirstName$",
"MiddleName": null,
"LastName": "$plan.LastName$",
"ExternalEmail": "$plan.ExternalEmail$",
"Pronouns": "$plan.Pronouns$",
"UserName": "$plan.UserName$",
"Activation":{
"IsActive": true
}
}

A null value is an expected value for Pronouns from the source system. When a null value is received, the intention is for the existing Pronouns value in the target source to remain unchanged rather than being cleared.

For other Pronouns values, the update works as expected and the value is successfully updated in the target source. However, when a null value or empty string is received from the source system, the update fails with the following error:

Parameters", "status": 400, "detail": "Request has missing or invalid parameters."

HTTP Error Code: 400

As a side note, there is also a Before Provisioning (BP) Rule configured for this source.

I am curious to understand what would be the best way to handle a null value in this scenario as it is a expected value which we need to pass through, while ensuring that the existing Pronouns value in the target source is not cleared or modified.

regards

ISC omits values from the provisioning plan if they have no value. There are some examples of workarounds on post such as the following:

Matt

Hi @MattUribe

Thanks for your reply,

In the first article, it tells below

“if the value for an attribute calculated in your update policy already matches what is currently on the account on the cube, the provisioning compilation process filters that attribute out of the resulting provisioning plan”

but in my situation, the value is null and which is different to target system value, so there is a change there. Also even if it ignores, it should not error it out. By looks it is null handling issue.

Second article is all about injecting values which are not in provisioning plan, which is slightly different to this use case.

Another thing I can try is, in the BP rule check the pronoun attribute value and inject value null forcefully if it is null or empty

If you replicate the request in Postman passing null for the value of “Pronouns”, does it succeed?

@lalithajay
Since you already have a Before Provisioning rule on this source (SailPoint’s docs call it the Web Services Before Operation Rule), that’s the right place to fix this rather than the JSON template, and it can handle both your null and empty-string cases in one pass.

Worth separating those two cases first, since they’re probably not hitting the same mechanism. @MattUribe point that ISC drops AttributeRequests with no value from the plan is confirmed behavior, from this thread about a different attribute, and that’s already the outcome you want for a true null. An empty string is different, “” is still a value, so there’s a real chance ISC keeps that AttributeRequest in the plan instead of omitting it, which would explain why both null and empty string are producing the same 400 for you even though only one of them should be getting dropped automatically.

The fix is to make your rule handle both the same way: look up the Pronouns AttributeRequest on the AccountRequest, and if its value is null or an empty string, remove it from the plan so it collapses into the same “no value, don’t touch the target” behavior ISC already applies correctly to true nulls.

import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.ProvisioningPlan.AttributeRequest;

for (AccountRequest accountRequest : Util.iterate(provisioningPlan.getAccountRequests())) {
    AttributeRequest pronounsReq = accountRequest.getAttributeRequest("Pronouns");
    if (pronounsReq != null) {
        Object value = pronounsReq.getValue();
        if (value == null || "".equals(value)) {
            accountRequest.remove(pronounsReq);
        }
    }
}

That mirrors the corrected pattern in this thread on removing an AttributeRequest from a Before Provisioning rule, just with a null/empty check instead of the identity-type condition they were using.

If that doesn’t fully solve it, worth knowing this rule type is also handed requestEndPoint directly, which per SailPoint’s documentation already contains the built request body as JSON, so you can inspect and correct it directly as a second lever in the same rule if the plan-side fix above turns out to run too late to affect what actually gets sent:

Map body = requestEndPoint.getBody();
Map jsonMap = JsonUtil.toMap((String) body.get("jsonBody"));
Object pronouns = jsonMap.get("Pronouns");
if (pronouns == null || "".equals(pronouns)) {
    jsonMap.remove("Pronouns");
}
body.put("jsonBody", JsonUtil.render(jsonMap));
requestEndPoint.setBody(body);
return requestEndPoint;

I don’t have a way to confirm from the docs alone whether the plan-side removal is guaranteed to happen before the body gets built or after, so I’d try the AccountRequest-level fix first since it’s the more standard pattern, and fall back to editing requestEndPoint directly if an empty Pronouns value still shows up in the outbound request.

The “x” suffix trick @MattUribe linked is solving a different problem, forcing an update through when the value hasn’t changed, not what you need here, so I’d leave that one aside.

Hello Lalitha. Your approach looks correct. This appears to be the Brightspace/D2L Update User API, where "Pronouns": null leaves the existing value unchanged, while "" clears it.

I would first test the same payload in Postman with "Pronouns": null, as @MattUribe suggested. If that succeeds, use the Web Services Before Operation Rule to add Pronouns: null back into the final request when ISC removes the null value from the plan.

Have you tried speaking to the software vendor and asking them to build a PATCH endpoint?
That would solve all the problems that you are running into with null values

Hi @punna0001

Thanks for your reply,

Yes this is D2l API… and find below observations, by looks the error is happening well before ? I also did the BP rule modification

Tried directly on postman with below payload and it works without errors

{
“OrgDefinedId”: “111111111”,
“FirstName”: “test”,
“MiddleName”: “testmn”,
“LastName”: “test2”,
“ExternalEmail”: “test@test.com”,
“UserName”: “111111111”,
“Activation”:{
“IsActive”: true
},
“Pronouns”: null
}

and then tried within sailpoint ISQ,D2l HTTP operation (update path), it works with below payload

{
“OrgDefinedId”: “$plan.UserName$”,
“FirstName”: “$plan.FirstName$”,
“MiddleName”: null,
“LastName”: “$plan.LastName$”,
“ExternalEmail”: “$plan.ExternalEmail$”,
“Pronouns”: null,
“UserName”: “$plan.UserName$”,
“Activation”:{
“IsActive”: true
}
}

but it fails with below payload when we replace “Pronouns”: "$plan.Pronouns$, that is

{
    "OrgDefinedId": "$plan.UserName$",
    "FirstName": "$plan.FirstName$",
    "MiddleName": null,
    "LastName": "$plan.LastName$",
    "ExternalEmail": "$plan.ExternalEmail$",
     "Pronouns": "$plan.Pronouns$",
    "UserName": "$plan.UserName$",
  "Activation":{
        "IsActive": true
    }
}

by looks the issue is with $plan.Pronouns$ when it comes to null and empty string, but I have defined ‘Pronouns’ in schema and response mappings etc. To prove when it comes to not null values it works and updates the target.

so in nutshell the issue is in $plan.Pronouns$ when it comes to null values (and empty string) and in events log it has below failure,

Message: 400 : Bad Request : {\"type\":\"http://docs.valence.desire2learn.com/res/apiprop.html#invalid-parameters\",\"title\":\"Invalid Parameters\",\"status\":400,\"detail\":\"Request has missing or invalid parameters.\"}, HTTP Error Code: 400"]

So by looks failure happening well before BP rules etc based on above facts?

Hi @officialamitguptaa

Thanks for the detailed answer, I did the BP rule slightly differently basically to re-inject the null value against pronouns when param is null or empty as direct postman call worked with null,

Interestingly When pronoun is not null it works, but from trusted source moment we have null or empty value for pronoun it fails with below error (bottom of the msg)

By looks in below HTTP update operation body within sailpoint , it does not like $plan.Pronouns$ when it comes to null is my observation

{
“OrgDefinedId”: “$plan.UserName$”,
“FirstName”: “$plan.FirstName$”,
“MiddleName”: null,
“LastName”: “$plan.LastName$”,
“ExternalEmail”: “$plan.ExternalEmail$”,
“Pronouns”: “$plan.Pronouns$”,
“UserName”: “$plan.UserName$”,
“Activation”:{
“IsActive”: true
}
}

Below error in event logs for null or empty Pronouns

{\"type\":\"http://docs.valence.desire2learn.com/res/apiprop.html#invalid-parameters\",\"title\":\"Invalid Parameters\",\"status\":400,\"detail\":\"Request has missing or invalid parameters.\"}, HTTP Error Code: 400"]

@lalithajay -

D2L’s own docs actually settle part of this, and they point back to treating null and empty string as different actions rather than collapsing them into one.

From the Users resource docs, on Pronouns specifically: “If you provide null for this field, the previously set value will not be touched. If you want to reset the system-defined pronouns to empty for a user, you should provide an empty string (”“) value for this field.” So null and “” aren’t interchangeable on D2L’s side. Null means leave whatever’s already there alone, “” means actively clear it. Your revised rule sends null for both cases now, which means a record that goes from having a pronoun to being genuinely blank at the source will never actually clear on the target, it’ll just get silently skipped every run. Worth reverting to handling them separately for that reason alone, independent of the 400.

On the 400 itself: Pronouns isn’t a required field in that same schema, null is a documented and accepted value, and your Postman test already proved a real null gets through fine. So the 400 pretty much has to mean ISC isn’t actually sending a clean null when $plan.Pronouns$ has nothing to resolve, it’s sending something else that looks like a value to D2L but isn’t a valid one. Worth confirming exactly what’s going out before guessing further: log body.get("jsonBody") at the top of your rule, before your fix logic touches anything, and check the rendered payload for an empty-Pronouns case. That’ll show whether the key’s getting dropped entirely, coming through as "", or something else, and whichever it is tells you precisely what you’re patching instead of guessing blind.

The fix itself stays the same shape as the requestEndPoint approach from my last reply, just sending the value that actually matches the source condition instead of null for both:

Map body = requestEndPoint.getBody();
Map jsonMap = JsonUtil.toMap((String) body.get("jsonBody"));
Object pronouns = jsonMap.get("Pronouns");
if (pronouns == null) {
    jsonMap.put("Pronouns", null);
} else if ("".equals(pronouns)) {
    jsonMap.put("Pronouns", "");
}
body.put("jsonBody", JsonUtil.render(jsonMap));
requestEndPoint.setBody(body);
return requestEndPoint;

Both branches look like they’re setting back what was already there, but the point isn’t the value, it’s forcing that key to exist in the map with exactly that value before re-serializing, rather than trusting whatever $plan.Pronouns$ already rendered.

Thanks Lalitha. Looking at your test, I think the issue is with $plan.Pronouns$, not D2L accepting null.

If Pronouns is missing from the provisioning plan, SailPoint removes that key from the JSON instead of sending null (body handling). Having it in the schema does not guarantee it is present in the plan.

I would keep:

"Pronouns": null

in the Update body, then use a Web Services Before Operation Rule to replace it when the plan contains a Pronouns value.

If your change was in a Before Provisioning Rule, that is a different rule and will not directly control the final HTTP body.

D2L treats null as leave unchanged and "" as clear the value (UpdateUserData), so handle those two cases based on the behavior you want.

Hi @punna0001

Thanks for your reply, am thinking below approach…considering there is already a BP rule in place

keep “Pronouns”: null so that no errors in events

but in BP rule, conceptually get the 'Pronouns" from account (or even from Identity) and reinject as follows

.....

Account account =  idn.getAccountByNativeIdentity(accountRequest.getApplicationName(), nativeIdentity);

.....

String attributeValue =StringUtils.trimToNull(idn.getAccountAttribute(account, "Pronouns"));

...

if (attributeValue == null) {

                           
                            accountRequest.add(
                                createAttributeRequest(
                                    "Pronouns",
                                    null,
                                    ProvisioningPlan.Operation.Set
                                )
                            );

                        } 

as a side note, business asked us to treat null, “” and assign null so that it will not change in D2l

let me now whether you see any issue handling logic in BP rule as above,

Thanks @officialamitguptaa

Certainly this is worth trying and agree your rational behind null vs empty, it just that business asked us to treat both as same, that is dont change downstream for these two.

Also we got lot of BP rules but not Web Services Before Operation Rules

Considering we got Identity Secure Cloud and I do use VSCode, what is involved creating Before Operation Rule, any steps that I can follow to create a one and deploy,

I presume easily we can develop the code and attach that to the the operation via VSCode?

Appreciate some help on that direction, so that I can try out above

Regards

Since the business wants both null and "" to leave D2L unchanged, I would keep "Pronouns": null in the Update body.

I would not read Pronouns from the existing account, because that gives the stored target value, not necessarily the incoming value.

Instead, in the Web Services Before Operation Rule, read Pronouns from provisioningPlan and overwrite the hardcoded null only when the value is non-empty. If it is null, empty, or absent, leave the hardcoded null unchanged.

Your existing BP Rule can stay for its other logic, but I would not use it to reinject null here. The Before Operation Rule controls the final request body. (Before Operation Rule)

That should give the behavior you want: real values update D2L, while null/empty leave Pronouns unchanged.

Hi

Thanks for your information, I wrote a simple before rule as below of type “WebServiceBeforeOperationRule” firstly to see the output of body

import java.util.Map;

log.error("===== BEFORE OPERATION RULE START =====");

if (requestEndPoint != null) {

    log.error("Operation: " + requestEndPoint.getOperationType());
    log.error("Context URL: " + requestEndPoint.getContextUrl());

    Map body = requestEndPoint.getBody();

    if (body != null) {

        log.error("BODY MAP: " + body);

        Object jsonBody = body.get("jsonBody");

        log.error("JSON BODY:");
        log.error(String.valueOf(jsonBody));
    }

    log.error("HEADERS: " + requestEndPoint.getHeader());
}

log.error("===== BEFORE OPERATION RULE END =====");

return requestEndPoint;

and then via VSCode attach the rule to the relevant operation in the source as below

"operationType": "Update Account",
   "beforeRule": "D2L Before Update Rule",


Given it is connector level rule (not clould) I was expecting the logs to appear on CCG.log
but I cannot see the debug entries after an update operation. Also I did not enable the logs on VA given it is log.error also note we have ISC

Hi,

I got below rule done, but it is not firing, my biggest doubt is the way I am testing, I am using API to update the trusted source account, so that it propagate to target accounts.

In our setup in addition to aggregation we have this way of execution as well to cater for dynamic needs instead of waiting aggregation to occur.

as a side note, definitely before provisioning rule fires for API based updates

I can certainly see all the down stream getting updated, but this rule does not seem to fire, how ever in logs sometime I can see log entries related, by looks it is when normal aggregation fires? pls ignore log.error, this is to make sure it fires, also note null is hardcoded in the http update operation against the Pronouns, I will override if not empty/null only

import java.util.Map;
import java.util.HashMap;
import org.apache.commons.lang3.StringUtils;
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.ProvisioningPlan.AttributeRequest;

log.error("===== BEFORE OPERATION RULE START =====");

String pronoun = null;

// Get Pronoun from ProvisioningPlan
if (provisioningPlan != null) {

    for (AccountRequest accountRequest : provisioningPlan.getAccountRequests()) {

        AttributeRequest attrReq = accountRequest.getAttributeRequest("Pronouns");

        if (attrReq != null) {
            pronoun = StringUtils.trimToNull(String.valueOf(attrReq.getValue()));
            break;
        }
    }
}

log.error("Pronoun from provisioning plan = " + pronoun);

if (requestEndPoint != null) {

    log.error("Operation: " + requestEndPoint.getOperationType());
    log.error("Context URL: " + requestEndPoint.getContextUrl());

    Map body = requestEndPoint.getBody();

    if (body != null) {

        Object jsonBodyObj = body.get("jsonBody");

        if (jsonBodyObj instanceof Map) {

            Map jsonMap = (Map) jsonBodyObj;

            // Only update if Pronoun is valid
            if (pronoun != null) {

                jsonMap.put("Pronouns", pronoun);

                log.error("Updated JSON Pronoun to: " + pronoun);
            } else {
                
                log.error("Pronoun is null, empty, or 'Not entered'. Keeping existing JSON value.");
            }

            body.put("jsonBody", jsonMap);
            requestEndPoint.setBody(body);

            log.error("Updated JSON BODY: " + jsonMap);
        }
        else {
            log.error("jsonBody is not a Map. Type = "
                + (jsonBodyObj != null ? jsonBodyObj.getClass().getName() : "null"));
        }
    }

    log.error("HEADERS: " + requestEndPoint.getHeader());
}

log.error("===== BEFORE OPERATION RULE END =====");

return requestEndPoint;

let me know any thoughts,

Hello Lalitha. Your API test is valid only if it actually triggers the target Web Services Update Account operation. I would check:

  1. Confirm provisioning activity is generated for this target account.
  2. Export the source and verify beforeRule: "D2L Before Update Rule" is attached to the exact Update Account entry.
  3. Check ccg.log for your START/END markers.

There are also two issues in the rule.

jsonBody is handled as a String in SailPoint’s example, so this will normally fail:

jsonBodyObj instanceof Map

Parse it with JsonUtil.toMap(). Also, avoid:

StringUtils.trimToNull(String.valueOf(attrReq.getValue()))

because a real null becomes the string "null".

Use:

Object value = attrReq.getValue();

if (value != null) {
    pronoun = StringUtils.trimToNull(value.toString());

    if ("Not entered".equalsIgnoreCase(pronoun)) {
        pronoun = null;
    }
}

Then only modify the body when pronoun != null. That way your hardcoded "Pronouns": null remains untouched for null/empty values. Connector-rule logs should appear in ccg.log on the VA.

Thanks I did the coding,

Previously I attached the rule via vsCode I attached as below

                ....
                "httpMethodType": "PUT",
                "pagingInitialOffset": 0,
                "sequenceNumberForEndpoint": "10",
                "uniqueNameForEndPoint": "UpdateUser",
                "beforeRule":"D2L Before Update Rule",' 
                 ......

 

However just to make sure, I removed above and then I tried to attach via v3 API patch ({{baseUrl}}/sources/:id) with application/json-patch+json

with payload [

{

"op": "replace",

"path": "/connectorAttributes/connectionParameters/9/beforeRule",

"value": "D2L Before Update Rule"

}

]

but it fails with below, am curious any other task I need to do to attach or whether my VScode is correct etc

“messages”: [

    {

        "locale": "und",

        "localeOrigin": "REQUEST",

        "text": "The request was syntactically correct but its content is semantically invalid."

Your VS Code placement looks correct. Since you removed beforeRule, I would use add rather than replace:

[
  {
    "op": "add",
    "path": "/connectorAttributes/connectionParameters/9/beforeRule",
    "value": "D2L Before Update Rule"
  }
]

SailPoint documents add for a value that is not currently configured, and replace for changing an existing value. Also, endpoint sequence 10 maps to index 9 (Connector Rules).

Before patching, GET /v3/sources/{id} and confirm connectionParameters[9] is UpdateUser, and confirm D2L Before Update Rule already exists with type WebServiceBeforeOperationRule.

After the PATCH, GET the source again and verify:

"beforeRule": "D2L Before Update Rule"

If beforeRule is already present, use replace instead.