WebInvoke = "POST" or "GET" Method for REST Service on WCF

When should post vs get be used? 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); 
+7
wcf
source share
4 answers

POST should be used when sending updates to the server.

GET should be used when retrieving an object from the server.

You might want to read what HTTP verbs mean in the context of RESTful services:

+13
source share

POST every time you change any state on the server, for example, updating a database, delete it. GET for read-only selection, like database selection.

+6
source share

GET: get a collection of records (as a submission document) or one record (as an input document).

POST: create a new entry from the input document.

PUT: Update an existing record using an input document.

DELETE: delete the entry.

+2
source share

But in C # you get a response in GET. so the full answer is, GET should be used when retrieving the object from the server and used when sending updates from the server.

0
source share

All Articles