Rose
Rose

Reputation: 2882

RestFul Get vs Post

I know Restful Get operation is for retrieving info. And Restful Post is for creating/inserting a resource in which we don't have unique identifier.

But some one just asked me "what are the advantages of Restful GET over Restful POST? what are the advantages in terms of the server side capability?"

Upvotes: 1

Views: 6877

Answers (3)

suing
suing

Reputation: 2878

You can use GET or POST to do anything you want. If you deviate from the HTTP Standard then you are going to have to explain that to you consumers and you've completely undermined REST principles. An example of this is when websites used the GET to delete resources. Then when Google started crawling the site it stated deleting resources. GET is supposed to be idempotent so this wouldn't have happened if the service creators followed the HTTP Spec.

Upvotes: 1

user949300
user949300

Reputation: 15729

I think the answer "they" want, at least the one I would try, is that GETs are idempotent (make no change to the server) and can be cached for speed and tremendous scalability. Handling lots of GETs is (relatively) easy on the server. A POST creates things on the server, so it changes things, cannot be "cached", is more work, harder to scale. blah blah...

Upvotes: 10

Affe
Affe

Reputation: 47994

There is no difference whatsoever in server-side capability that you don't make yourself. Whether the request was a GET or a POST is nothing but a piece of data on the HttpServletRequest object by the time it gets to you. You could handle them completely differently, or with the exact same code.

Upvotes: 1

Related Questions