在 RestSharp 中获取 REST 请求的原始 JSON 数据

Ann*_*off 4 c# rest json restsharp

我使用 RestSharp 访问服务器 API。

RestClient client = new RestClient(serverUrl);

JObject parameters = new JObject
        {
           new JProperty("Param1", p1),
           new JProperty("Param2", p2)
        }; 

RestRequest request = new RestRequest("/Foo", Method.POST);
request.AddParameter("application/json; charset=UTF-8", parameters, ParameterType.RequestBody);
Run Code Online (Sandbox Code Playgroud)

有没有办法在 RestSharp 中获取 REST 请求的原始 JSON 数据?

Ale*_*rev 5

此刻的答案是否定的。实际请求的所有部分,包括带有查询参数的 URL、正文和标头,仅在ConfigureHttp私有方法中构造。