Reputation: 20078
When should use post vs get? in a REST service on WCF?, below is my interface
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
string DoLodge(string Id, Lodge value);
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
LodgeLevel[] GetLodgeLevels(string Id);
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
long GetLodgeCount(string Id);
Upvotes: 7
Views: 33599
Reputation: 23
But in C#, you receive a response in GET. so the complete answer will be, GET should be used when retrieving an object from the server and used when sending an update back from the server.
Upvotes: 0
Reputation: 245429
POST should be used when sending an update back to the server.
GET should be used when retrieving an object from the server.
You might want to read up on what the HTTP Verbs mean in the context of RESTful services:
Upvotes: 15
Reputation: 21
GET: Get a collection of entries (as a feed document) or a single entry (as an entry document).
POST: Create a new entry from an entry document.
PUT: Update an existing entry with an entry document.
DELETE: Remove an entry.
Upvotes: 2
Reputation: 1038890
POST everytime you are modifying some state on the server like database update, delete. GET for readonly fetching like database select.
Upvotes: 7