- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在为 RSS 阅读服务构建一个客户端。我正在使用 RestSharp库与他们的 API 进行交互。
API 声明:
When creating or updating a record you must set
application/json;charset=utf-8
as theContent-Type
header.
我的代码是这样的:
RestRequest request = new RestRequest("/v2/starred_entries.json", Method.POST);
request.AddHeader("Content-Type", "application/json; charset=utf-8");
request.RequestFormat = DataFormat.Json;
request.AddParameter("starred_entries", id);
//Pass the request to the RestSharp client
Messagebox.Show(rest.ExecuteAsPost(request, "POST").Content);
但是;服务返回错误
Error 415: Please use the 'Content-Type: application/json; charset=utf-8' header
为什么 RestSharp 不传递 header ?
最佳答案
my blog 上提供的解决方案未测试超过 RestSharp 1.02 的版本。如果您针对我的解决方案的具体问题提交对我的回答的评论,我可以更新它。
var client = new RestClient("http://www.example.com/where/else?key=value");
var request = new RestRequest();
request.Method = Method.POST;
request.AddHeader("Accept", "application/json");
request.Parameters.Clear();
request.AddParameter("application/json", strJSONContent, ParameterType.RequestBody);
var response = client.Execute(request);
关于c# - 使用 RestSharp 设置 'Content-Type' header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17815065/
我正在使用 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
我是一名优秀的程序员,十分优秀!