lets say we have a "door api" and I want to create a resource to close the door.
I could do this in 3 ways:
- traditional way using PUT with payload {id: XX, color: YY, closed: true}
- advantages: simple and follows standard
- disadvantages: client needs to edit the door instance by editing closed property and send the value to the backend. If request fails then client needs to restore value to original.
- traditional way using PATCH with payload {closed: true}
- advantage: simple and reduces payload to the minimum
- disadvantages: same as PUT
- create a resource /door/close-door/{door id} with PUT?
- advantages: client code is simple, just call resource and only need to change door object on client if request is successful
- disadvantages: I am not sure whether this is the right way to create a resource URI
QUESTION 1: could someone please help me to understand any disadvantage of option 3 (which is my favourite one) and if any issue with that URI?
QUESTION 2: I guess I should use PUT verb on option 3... does it makes sense to have PUT without payload?
thanks