0
我必须使用RestSharp将一些数据放入API中。Restharp PUT自定义标题
的API资源是:/客户/服务/财务/ {财政-ID} /子/ {子类别-ID}
从模板参数除此之外,还有一些查询参数: 组织-ID(字符串) 运营商ID(字符串)
并且还,请求内容类型必须是application/XML
的办法,我尝试使用RestSharp创建这个PUT请求:
RestClient client = new RestClient(url);
client.Authenticator = Auth1Authenticator.ForRequestToken(Config.getVal("api_key"), Config.getVal("secret_key"));
IRestRequest request = new RestRequest("", Method.PUT);
request.RequestFormat = DataFormat.Xml;
request.AddParameter("organization-id", Config.getVal("params.org"));
request.AddParameter("operator-id", "Accounting");
IRestResponse response = client.Execute(request);
但我只得到HTTP状态415 - 不支持的媒体类型
你能帮我解决这个问题吗? GET请求像魅力一样工作。
在哪里你正在发送的内容?我看不到添加到请求正文中的任何内容 - 现在您只需要url path + query字符串。 –
这是要求一个XML,我有架构,但我不知道如何将它与请求一起发送。 – HTB222