restsharp - 将 IRestResponse 转换为 IRestResponse<T>

标签 restsharp

我已经执行了RestRequest并得到非类型 IRestResponse .

如何将其转换为IRestResponse<T>

例如IRestResponse<MyErrorData>IRestResponse<MyData>

最佳答案

您需要使用 Execute 的通用重载:

var client = new RestClient();
client.BaseUrl = BaseUrl;
request.AddParameter("AccountSid", _accountSid, ParameterType.UrlSegment);
var response = client.Execute<T>(request);

Execute<T>是获取输入响应的关键。

关于restsharp - 将 IRestResponse 转换为 IRestResponse<T>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26102691/

相关文章:

c# - 如何在 ASP.NET 和 C# 中重用这个基于 Ultimate RestSharp 客户端的 API 客户端?

c# - 无法使用 Nuget 在 Azure 函数中导入和使用 RestSharp

c# - RestSharp 不对请求进行 UTF-8 编码

c# - 在 C# 中,我可以在 Restsharp 中设置一些 httpclienthandler 属性吗?

c# - 使用 RestSharp 将 JSON 反序列化为对象或数组

silverlight - RestSharp 诉 WebClient?

asp.net-mvc-4 - WebAPI 请求格式的异常

c# - 使用 RestSharp 客户端反序列化嵌套的 JSON 响应

oauth - 如何在OAuth中使用RestSharp?

c# - RestSharp - 反序列化具有无效键名的 json 响应(包含句点)