Set 'Content-Type' header using RestSharp

后端 未结 5 993
眼角桃花
眼角桃花 2020-12-08 19:39

I\'m building a client for an RSS reading service. I\'m using the RestSharp library to interact with their API.

The API states:

When creating

5条回答
  •  时光说笑
    2020-12-08 19:56

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

提交回复
热议问题