FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    Java client + PATCH + nulls

    Scheduled Pinned Locked Moved
    General Discussion
    0
    4
    197
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      DmitryZ
      last edited by

      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 the data map.

      Any suggestions how to use patches in such cases?

      Thank you!

      1 Reply Last reply Reply Quote 0
      • danD
        dan
        last edited by

        My understanding of the java client is that you use a map of objects for the patch method.

        https://github.com/FusionAuth/fusionauth-java-client/blob/master/src/main/java/io/fusionauth/client/FusionAuthClient.java#L1727

        Maybe the best path forward would be to retrieve the user, extract the data object, make your changes, and provide the new data object wholesale?

        --
        FusionAuth - Auth for devs, built by devs.
        https://fusionauth.io

        1 Reply Last reply Reply Quote 0
        • D
          DmitryZ
          last edited by DmitryZ

          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 keeping WRITE_NULL_MAP_VALUES in the default true state.

          1 Reply Last reply Reply Quote 0
          • danD
            dan
            last edited by

            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.

            --
            FusionAuth - Auth for devs, built by devs.
            https://fusionauth.io

            1 Reply Last reply Reply Quote 0
            • First post
              Last post