Hi all,
We’re in the process of upgrading from version 5 to 6 of the Okta dotnet SDK and have come across a use case that was working in 5.x, but appears to be failing in 6.x
We’re using UserApi.PartialUpdateUserAsync() to set a single custom property, but we’re getting back a validation failure from the API along the lines of firstName and lastName are mandatory.
I’ve swapped in a faux Okta API to capture what exactly is being HTTP posted. The 5.x version posts the following payload:
{"profile":{"On_Behalf_Of":"0d56df5b-3f04-4725-8c7a-15afb966e238"}}
But the 6.x version posts this:
{"profile":{"city":null,"countryCode":null,"firstName":null,"lastName":null,"mobilePhone":null,"postalAddress":null,"primaryPhone":null,"secondEmail":null,"state":null,"streetAddress":null,"zipCode":
null,"On_Behalf_Of":"0d56df5b-3f04-4725-8c7a-15afb966e238"}}
So it appears the JSON serialisation of UserProfile is including null values. For completeness, the new 6.x code is as follows:
var partialUpdate = new UpdateUserRequest {Profile = new UserProfile {AdditionalProperties = new Dictionary<string, object>()}};
partialUpdate.Profile.AdditionalProperties.Add("Foo", newValue);
await _oktaUserApi.PartialUpdateUserAsync(uid, partialUpdate);
Is there a way for force null values to not be serialised?
Thanks