号外号外: 原[图享网]更名为 码友网(codedefault.com) 啦,感谢大家一路上的陪伴与支持。代码的世界里,码友网与大家一起同行!

.NET[C#]RestSharp GET/POST/DELETE使用示例演示教程

.NET 作者: Rector 888阅读 0评论 0收藏 收藏本文

郑重申明:本文未经许可,禁止任何形式转载

RestSharp GET/POST/DELETE使用示例演示教程

GET

var client = new RestClient("192.168.0.1");
var request = new RestRequest("api/item/", Method.GET);
var queryResult = client.Execute<List<Items>>(request).Data;

POST

var client = new RestClient("http://192.168.0.1");
var request = new RestRequest("api/item/", Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddBody(new Item
{
ItemName = someName,
Price = 19.99
});
client.Execute(request);

DELETE

var item = new Item(){//body};
var client = new RestClient("http://192.168.0.1");
var request = new RestRequest("api/item/{id}", Method.DELETE);
request.AddParameter("id", idItem);

client.Execute(request)

阅读了该文章的人还浏览了...

本文永久链接码友网 » .NET[C#]RestSharp GET/POST/DELETE使用示例演示教程

发布于: 2018-01-04 10:25:39
分享扩散: