Java client + PATCH + nulls
-
Hi there!
I'm using the Java client library and want to call the
patchUser()
method.
The API documentation suggests to use nulls to clean up currently assigned field values. But the client implementation uses an internal objectMapper that seems always skips nulls. I don't see an option to provide my own object mapper.
To add a bit more details - I need to clean up some attributes and sub-sections of thedata
map.Any suggestions how to use patches in such cases?
Thank you!
-
My understanding of the java client is that you use a map of objects for the patch method.
Maybe the best path forward would be to retrieve the user, extract the
data
object, make your changes, and provide the newdata
object wholesale? -
Yeah, this definitely works, thank you for the suggestion!
It just requires always have an additional API call to read the current state and sending the full object definition back and forth on any single attribute update.
What defeats the purpose of having the PATCH method that exists specifically to avoid this.A proper patch implementation would require a different ObjectMapper without
JsonInclude.Include.NON_NULL
and keepingWRITE_NULL_MAP_VALUES
in the defaulttrue
state. -
Understood. If you would like to file an issue detailing the behavior you've outlined here, we welcome community feedback and work it into our eng team roadmap. You can file the issue here, please feel free to reference this forum post.