Can I use HTTP PUT for a property?

106 Views Asked by At

I'm designing an API that will replace one property of a resource "a".

{
   "a": {
      "b": "hello",
      "d": "xxx"
   },
   "c": "hello2"
}

I have 2 options seem possible:

  1. PUT /resources/{id}/a In this way, we treat a as a sub-resource. However, it's kinda debatable whether it's a resource or just a property. If it's just a property, is it OK to PUT on a property?
  2. PATCH /resources/{id} In this way, we can do a "merge-patch" which is my company's current standard. However, for "merge-patch", there is no way to require the user to pass in all the properties, the user is able to skip some properties, he doesn't want to update. We have some polymorphic models. This makes the implementation very hard.

This becomes a hard design question for us. Please shed some light on me!

0

There are 0 best solutions below