Data payload for PUT and PATCH

Tagged: ,

This topic has 2 replies, 2 voices, and was last updated 6 years, 3 months ago by Brad Tumy.

  • Author
    Posts
  • #3265
     Brad Tumy
    Participant

    When updating a user record via REST using a PUT replaces an entire object deleting any attributes that were not included in the JSON payload. So, using a PATCH operation is best for situations where you want to update a partial record.

    Is it possible to use PUT but use the same format for the data payload as you would for a PUT? Ideally we would like to just send the user JSON object without having to specify the operation, field and value for each attribute that we are updating.

    #3266
     Jake Feasel
    Moderator

    The only way you could accomplish what you are suggesting is by creating a custom endpoint and issuing a PUT request there, rather than directly on your given resource. Then you would have to add the logic to the endpoint to loop through all of the keys of your structure in order to build a set of patch operations that could ultimately be included in a call to openidm.patch(). Shouldn’t be too hard to implement, I don’t imagine.

    #3268
     Brad Tumy
    Participant

    Thanks Jake. That definitely looks like a reasonable approach.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

©2021 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?