Santos
Santos

Reputation: 71

Can I use PUT http method to retrieve the data instead of using GET

Is it possible to design this way. Can put method retrieve the data?

Upvotes: 1

Views: 1122

Answers (3)

Arfat Binkileb
Arfat Binkileb

Reputation: 671

To answer your question. Yes you can.

Any of of GET,POST,PUT,DELETE methods can return a Representation (Response Object) No framework will stop you (Most).

Should I do that?

Well, These HTTP verbs are there for a reason. In other words, they describe what they do.

In case of PUT:

Client sends Representation to update existing one. Server returns either 200 with empty body / 200 with newly updated representation

Just to add, If you don't want GET to do what you trying to do, Use POST with some sensible URL

Upvotes: 2

Julian Reschke
Julian Reschke

Reputation: 42025

HTTP does not stop you from doing so, but why would you?

Upvotes: 1

Nicola
Nicola

Reputation: 61

Unfortunately not, officially the REST methods are

POST -> Create a new resource
GET ->  (Read) Gets an existing resource
PUT  ->  Updates a resource or changes its status
DELETE ->  Deletes a resource

More info here

Upvotes: -1

Related Questions