Not able to set firstname and lastname to null when updating user
gubi95 opened this issue · 4 comments
Describe the problem
While updating user using this method
I was not able to "reset" firstname and lastname by setting nulls to those properties. The problem causing this can be setting json null handling to ignore null values hereQuick solution to this could be setting NullValueHandling = NullValueHandling.Include
on JsonProperty
attribute:
auth0.net/src/Auth0.ManagementApi/Models/UserBase.cs
Lines 73 to 74 in 0428cde
What was the expected behavior?
Update firstname and lastname to null
Environment
- Version of this library used: 7.17.0
NullValueHandling.Ignore is very important for this endpoint because it's a PATCH. This allows the code to update only data that is set. Updating this to Include would send any unset property as null resulting in lost data and/or errors
I agree. PATCH should work just like you described. The problem is that we are not able to send information like "I want to clear this field". Or there is other way to do it?
Sorry for the delay. You indeed are not able to set the properties to null, and we can not stop ignoring null values as that would break alot of people and cause unexpected behavior as mentioned above.
For now, you might need to work around this by calling the endpoint yourself.
Leaving this open to see if we can improve how we handle PATCH endpoints in general, as I can see this being an issue for any PATCH operation.
With the current SDK, I believe there isn't much we can do to allow for this. The only recommendation we can do for now is to roll your own call.
Even thought we could make the JsonSerializerSettings configurable, that might cause unexpected behavior when you set NullValueHandling.Include
, so we are holding off from that for now. Happy to revisit in the future as needed.