PUT, DELETE and Hypermedia

18 views
Skip to first unread message

Lorenzo Lorenzo

unread,
Aug 8, 2022, 3:10:23 AM8/8/22
to restinpractice
Dear sirs,
I've just finished reading the book and I have a couple of questions concerning one of the core chapters, chapter 5.
Specifically, in section "Hypermedia protocols" and the related discussion PUT and DELETE verbs are used respectively on payment/ {userid} and receipt/{userid} in order to 1) play, 2) conclude the processing. Those two actions, because of application internal business rules, change the state of a different resource, order. In particular, deleting the receipt results in *only* changing the state of the order.
So, since their main action is a side effect to a different resource, should POST be a more appropriate action? 

Cheers


J G

unread,
Aug 8, 2022, 3:33:57 AM8/8/22
to restinp...@googlegroups.com
If you didn’t have intimate knowledge of the internal business rules would you think the same?


----------------------------------
From the phone

On 8 Aug 2022, at 17:10, Lorenzo Lorenzo <loren...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "restinpractice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to restinpractic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/restinpractice/56c5a990-4695-4d1e-babe-9d8598f05226n%40googlegroups.com.

Lorenzo Lorenzo

unread,
Aug 9, 2022, 4:02:04 AM8/9/22
to restinpractice
Ok, I got your point. Well, It's all a matter of perspective I suppose. I mean, if the DELETE or PUT actions change the application state transitions with respect to the order, of course the customer/client becomes aware that those actions influence in some way the internal state of the order resource.

On a second thought, I think I understood why PUT is used instead of POST: because you're *creating* the resource with the specific url "/payment/1234", not replacing it! (I was puzzled after having read the "resources updates: put vs post" box on page 114).

Thanks for your answers!

Cheers

Lorenzo Lorenzo

unread,
Aug 9, 2022, 11:32:53 AM8/9/22
to restinpractice
Oh, btw, exploring the discussions in this group, I've found a reference to Mark Nottingham's blog. In particular, this post has raised my attention:


Whereas the main topic is the partial update (another dilemma of the REST environment), Mark remarks how using PUT or PATCH can be misleading when the action exhibits also side effects:

While you can fit this sort of thing into a world view where you’re PATCHing a special-purpose resource that has side effects on other resources, I think it’s a looong stretch to say that this is just a PATCH; POST would make it more clear that something special is going on here and require that the protocol be really spelled out somewhere.

So, I think it's all a matter of perspective, there's not a definitive answer to my question.

Another useful resource I found in my journey:
Reply all
Reply to author
Forward
0 new messages