我是 C# 的新手,但仍在努力熟悉它的环境。
我想在获取模式下发出 REST 请求。给我 API 访问权限的人为我提供了以下信息:
HTTP Methods: GET
Authentication: None
Formats: xml
Parameters: format, apikey [GET], lang [GET], q [GET]
CURL Example: curl --get --data lang="de" --data q="query" --data apikey="QWERTY123456" http://jokr.info/api/v8/search/item.xml
而且我不知道如何将其放入 C# 中。 我尝试使用 WebClient,但我不知道如何将带有参数的请求付诸实践。
最佳答案
有一个流行的图书馆RestSharp .
这是一个例子:
var client = new RestClient("http://example.com");
var request = new RestRequest("api");
request.AddParameter("foo", "bar");
client.ExecuteAsync(request, response => {
// do something with the response
});
关于c# - 如何在 C# 中编写 REST Get-Request?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12250494/