electrode
electrode

Reputation: 285

which http verb/best practice to update an entity without payload to send?

purpose is really simple: i want to modify entities but i have no data to send in payload, as request is really easy. In fact, my url is something like :

/v1/{customerId}/release/old/subscriptions

==> the code update entity Subscription for customerId asked.

the question is: @GetMapping : ok but is not RESTFULL as entity is modified! @PutMapping : ok but no payload to send ! @PostMapping : ok but no payload to send !

what is best practice ?

i want to do some

Upvotes: 3

Views: 1340

Answers (1)

VoiceOfUnreason
VoiceOfUnreason

Reputation: 57239

which http verb/best practice to update an entity without payload to send?

The general rule is that you use POST unless the semantics of your message match a more specific method.

PUT with an empty payload is a request to make the current representation of the resource zero bytes long. Think "delete the contents of the file".

PATCH requests are supposed to include a patch-document in the payload; and so the meaning would be whatever an empty document of that particular media type means. I don't think I've ever heard of a case where an empty patch document does something interesting.

POST requests are intended for any semantic that isn't worth standardizing.

Upvotes: 3

Related Questions