且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

设置“的Content-Type”头使用RestSharp

更新时间:2022-06-15 22:15:56

提供的我的博客是不超过RestSharp的1.02版本测试。如果你对我的回答提交评论与您的​​具体问题,我的解决方案,我可以更新它。

The solution provided on my blog is not tested beyond version 1.02 of RestSharp. If you submit a comment on my answer with your specific issue with my solution, I can update it.

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);