-3

One of interviewer asked about i an answered like this

GET requests can be cached GET requests remain in the browser history GET requests can be bookmarked GET requests should never be used when dealing with sensitive data GET requests have length restrictions GET requests is only used to request data (not modify)

POST requests are never cached POST requests do not remain in the browser history POST requests cannot be bookmarked POST requests have no restrictions on data length

The difference between POST and PUT is that PUT requests are idempotent. That is, calling the same PUT request multiple times will always produce the same result. In contrast, calling a POST request repeatedly have side effects of creating the same resource multiple times.

But a last he didn't accepted my answer. And said that i not accepting HTTP methods. He need restful method definition of this methods.

So my Question how it will differ from HTTP Method to Rest methods???

Tim
  • 41,901
  • 18
  • 127
  • 145
waseem
  • 1
  • 3

2 Answers2

0

But a last he didn't accepted my answer. And said that i not accepting HTTP methods. He need restful method definition of this methods.

What your interviewer was probably looking for was something analogous to the Rails conventions for routing:

GET is used to fetch an item or a collection

POST is used to create a new item in a collection

PUT is used to update an item

To me, that sounds like your interviewer not actually understanding REST. Unfortunately, understanding a question differently than your interviewer does is not a useful place to be in when you want to win the job.

How it will differ from HTTP Method to Rest methods?

If we were going to be very careful and precise, we would say that REST doesn't have methods. REST is an architectural style; HTTP is an application protocol designed using that style.

REST says that there will be self contained request messages, and that the semantics of those interfaces will be uniformly understood for all resources.

HTTP says that the method token is the primary source for request semantics, and defines semantics for GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE. It also defines a process by which new method tokens (ex: PATCH) can be introduced.

Community
  • 1
  • 1
VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91
-3

In term of HTTP,

1)Get method is used to request for data using api.

2)Post method is used to send data to api and

3)Put method is used to edit the data.

you can say by using put method we can replace all current representations of the target resource with the request payload.

Bishan
  • 15,211
  • 52
  • 164
  • 258