-
Notifications
You must be signed in to change notification settings - Fork 272
Delete
According to W3 the Delete method does the following.
The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the operation has been carried out, even if the status code returned from the origin server indicates that the action has been completed successfully. However, the server SHOULD NOT indicate success unless, at the time the response is given, it intends to delete the resource or move it to an inaccessible location.
There are several ways you can do a Delete with Easyhttp.
This will send delete method to the uri given.
var http = new HttpClient();
http.Request.Accept = HttpContentTypes.ApplicationJson;
var result = http.Delete("http://localhost/trees?Id=1");
This would be the same as this.
var http = new HttpClient();
http.Request.Accept = HttpContentTypes.ApplicationJson;
var result = http.Delete("http://localhost/trees", new { .Id = 1});
Or for services that prefer parameters as Segments you can do this.
var http = new HttpClient();
http.Request.Accept = HttpContentTypes.ApplicationJson;
var result = http.Delete("http://localhost/trees/1");
This would be the same as this.
var http = new HttpClient();
http.Request.Accept = HttpContentTypes.ApplicationJson;
http.Request.ParametersAsSegments = true;
var result = http.Delete("http://localhost/trees", new { .Id = 1});