Should the rest services use only 4 http methods?

566 Views Asked by At

I'm learning REST and do have some knowledge of it.

I know that there are more than 4 http methods: PUT, GET,POST, DELETE, HEAD, OPTIONS, CONNECT. Ref: http://www.w3schools.com/tags/ref_httpmethods.asp

I have installed postman plugin and discovered there are other methods too like: COPY, LINK, UNLINK, PURGE. Ref : https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en

If these are http methods too, can someone please give me a reference url to go through the documentation for these?

Coming to my actual question: Should RESTful Web Services be built using only PUT, GET, POST and DELETE as many websites on internet explain REST using only these 4 HTTP Methods?

2

There are 2 best solutions below

0
On BEST ANSWER

Short answer: no. But, first, take Julian Reschke's advice into account: the RFC 2616 is dead. Take a look at these articles:

Of course you can use other methods. For example, there is the PATCH method and you should use it for partial updates. According to the RFC5789, the PUT method shouldn't make partial updates.

The PUT method is already defined to overwrite a resource with a complete new body, and cannot be reused to do partial changes. (http://www.ietf.org/rfc/rfc5789.txt).

It depends on the method semantics and if these semantics apply to your REST Service. One more example: suppose a client of your RESTful Service wants to request the metadata related to a resource instead of its representation (the data itself). How can you do that? In this case, you can use the HEAD method to present only the metadata associated to this resource (its fields/attributes, for example).

Updating the answer to include the link to the RFC 7231. Follow this link if you want to learn more about HTTP Methods and their semantics.

0
On

a) don't look at RFC 2616. It's obsolete.

b) the list of registered HTTP methods is over here: http://www.iana.org/assignments/http-methods/http-methods.xhtml (with pointers to the specifications)