我是 C# 的新手,仍然试图熟悉它的环境。

我想在 Get-Mode 下创建一个 REST-Request。给我 API-Access 的人向我提供了以下信息:

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 但我不知道如何将我的请求与参数一起执行。

最佳答案

有一个受欢迎的图书馆 ojita 。
这是一个例子:

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
});
翻译成 RestSharp

关于c# - 如何在 C# 中编写 REST Get-Request?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12250494/

10-11 17:35
查看更多