- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
这是 RestSharp 部门(以及 C# 部门)的一个菜鸟问题,所以如果这让您感到不快,请不要生气。
我最近开始在我的 C# 应用程序中使用 RestSharp,我已经让它通过 IRestRequest 返回我想要的内容。
问题是它返回的这个内容只能作为char
获取。
这可能有点含糊,所以这是我的代码:
IRestRequest applicationReq = new RestRequest("somewhere/something", Method.GET);
IRestResponse applicationResp = client.Execute(applicationReq);
我想实际使用返回的 applicationResp.Content
,但它似乎将此结果返回为 char
。
有什么方法可以将其转换为更有用的东西吗?例如,字典
?
到目前为止,我什至发现从 applicationResp.Content
中“提取”此数据的唯一方法是将其转储到列表中,如下所示:
List<char> ar = new List<char>();
ar = applicationResp.Content.ToList();
尽管给我的是 char
列表。
谁能给我推荐一种将内容放入 Dictionary
的巧妙方法?
最佳答案
Can anyone recommend me a neat way of putting the content into a Dictionary
如果您知道 REST 调用的返回类型是 Dictionary<TKey, TValue>
,您可以使用接受类型 T
的通用版本所需的返回类型:
IRestRequest applicationReq = new RestRequest("somewhere/something", Method.GET);
IRestResponse applicationResp = client.Execute<Dictionary<string, string>>(applicationReq);
Dictionary<string, string> returnedData = applicationResp.Data;
关于c# - RestSharp,将 IRestRequest 内容作为可用内容返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29764573/
我正在使用 RestSharp 访问 RubyOnRails API。您可能知道,RoR 喜欢参数名称采用 model_name[property] 形式。另一方面,RestSharp 不喜欢它。 F
我刚刚下载了 DropNet 来尝试使用它。我在尝试执行 new DropNetClient 时遇到异常: Method not found: System.String RestSharp.Rest
当我尝试使用 nuget 将 RestSharp 添加到可移植类库项目时,我得到以下信息: Could not install package 'RestSharp 104.1'. You are t
我有以下代码片段,它一直在我身上失败: ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => tru
当我像这样在 RestSharp 中发出请求时: var response = client.Execute(request); 我收到以下错误: "Unable to cast object of
有什么方法可以从 RestSharp RestRequest 中删除 header 吗? 我在项目页面中偶然发现了这个问题,但看不到它曾经被应用过: https://github.com/restsh
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我正在使用 RestSharp 将信息发送到 API。我想记录发送到此 API 的 XML,以便稍后进行调试。 我想做这样的事情: var request = new RestRequest(reso
下面是使用标准 HttpWebRequest 和 HttpWebResponse 完成的 POST 请求。基本上它发布带有一些参数的二进制文件。 我怎样才能用 RestSharp 做同样的事情? 来源
目前无法解决问题:无法将类型为“RestSharp.JsonArray”的对象转换为类型为“System.Collections.Generic.IDictionary”2[System.String
我使用了在 ASP.NET Framework version 4.5.1 上运行的 MVC Web 应用程序. 我做了 nopcommercePlugin .我正在将版本 3.4 升级到 3.5 更
我用过restsharp对于我的一些 .net 项目。我发现它对于从网络服务获取 Json 数据并将它们转换为 .net 对象非常有用。我需要一个类似的java框架。我想用它来为我的 android
最近我在用 RestSharp消耗我的 Restful 资源。并期望在服务器和客户端之间与 JSon 交换数据。下面是我的 C# 代码。 var client = new RestSharp.Rest
我的应用程序要求是使用签名程序集。我使用 Visual Studio 2012 命令工具签署了 RestSharp 程序集。应用程序构建成功,但运行时出现以下错误: Could not load fi
在特定情况下,我需要能够在请求/响应中禁用压缩。 使用 Firefox RestClient 我能够将一些 xml 发布到 Web 服务并使用单个 header 参数“Accept-Encoding”
我正在尝试使用 RestSharp(我的第一次)。我正在使用他们的示例: var client = new RestClient( "http://example.com" ); var reques
我查看了有关此问题的其他问题,但似乎没有任何内容可以回答我的问题。希望因为我的问题/问题似乎是一个简单的解决方案。 我使用 nuget 安装了 RestSharp。 using RestSharp;
我正在尝试使用 RestSharp 编码示例来连接到 MailGun。在下面的代码中,请参阅: client.Authenticator = new HttpBasicAuthenticator("X
我正在使用 RestSharp。我使用 XML 作为我的数据的传输编码,但后来我 had problems有了这个,所以我转而使用 JSON。现在我也遇到了问题! 在我尝试传递一个包含字节数组 (*)
我刚刚更新了在 ASP.NET Framework 4.5.2 版上运行的 MVC Web 应用程序。我正在使用 Twilio 发送 SMS 消息: var twilio = new TwilioRe
我是一名优秀的程序员,十分优秀!