4

I got asked to do a code review of a very simple one-route web service that when hit would simply restart an application on the system. The developer had coded this up as a POST which strikes me as odd.

Now I realize that this is not really the type of thing that HTTP is all about - you can't even query state - but is there a more appropriate HTTP verb? My intuition is that since this is mostly idempotent and creates no new resources it should be a PUT.

  • If the request is browser based, he may have done it to avoid caching the request. Honestly I dont see why it matters what verb is used for this sort of thing so long as its documented. – GrandmasterB Dec 12 '13 at 18:56
8

I would also use POST for this, though I can see an argument for PUT. Based on RFC 2616 and my own experience, PUT is usually reserved for updating or replacing a resource. While restarting an application could conceptually fall into that category, to me this seems more like a server-side action, which is typically the purview of a POST request.

  • Yeah, it's a POST. – Robert Harvey Dec 12 '13 at 18:57
  • PUT is useful when you want retry semantics. In this case, I don't think you want middleware retrying the restart command -- could get weird. Also agree that PUT is to create or update data that you want to fetch later, and that's not the case here. Go POST. – Rob Feb 16 '14 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.