0

I started learning web api recently. I know in web api we use get verb to retrieve data, post verb to insert data, put verb to update data, etc. Someone asked me why we need separate verbs for insert,update, delete etc. We can do delete by using the verb post or can do update using verb delete. Why then use separate verbs?

I searched it on the internet, but I am not able to find exact answer to his question. So I thought to ask here. Sorry for asking stupid question.

Irshad Faras
  • 153
  • 1
  • 1
  • 10
  • This is the definition for such methods http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html ...as you can see you can use for example, post, to update or deletion and you can use this document as a guideline...now web api is an implementation of the rest specification(http://www.restapitutorial.com/lessons/httpmethods.html), so in that specification, for every verb you have the corresponding operation(still you can use post for the create, update or delete, and get for read), but if you do that your are getting a little bit away from the spec. – Hackerman Sep 11 '17 at 15:21
  • 1
    Lets say that we have an spec that describes a fork and a spoon...then the creators of the fork and the spoon, they write another document, and they write, you should use the spoon for soup and the fork for spaguetti...you can use the spoon to eat the spaguetti, but, the fork it's more suitable.... – Hackerman Sep 11 '17 at 15:22
  • 1
    It's convention. If every programmer at each company used whatever verb they want (even making their own verbs, which is allowed), then every time you change jobs, you'll have to learn all the correct verbs in use there. It's far easier to standardize this. You can, if you want, use POST to perform a delete operation, but the folks who work with you will expect a DELETE verb, because *that is the convention*. –  Sep 11 '17 at 15:23
  • So it's convention... Thanks everyone for making it clear. – Irshad Faras Sep 18 '17 at 05:54

0 Answers0