C# rest将获得序列化输出

C# rest将获得序列化输出,c#,restsharp,C#,Restsharp,我正在寻找一种方法来访问AddBody调用的序列化结果 我正在使用内置的RestSharp序列化程序。 例如: class Foo { public string FooField; } void SendRecord() { var f = new Foo(); f.FooField = "My Value"; request.AddBody(f); // How do I get the serialized json resu

我正在寻找一种方法来访问AddBody调用的序列化结果

我正在使用内置的RestSharp序列化程序。 例如:

class Foo
{
    public string FooField;
}       

void SendRecord() 
{

    var f = new Foo();
    f.FooField = "My Value";

    request.AddBody(f);

    // How do I get the serialized json result of the add body call without 
    // data? I would like to log the serialized output of the add body call to
    // the database. 
    //Expected {"FooField":"My Value"}

    var response = client.Execute(request);
}

在RestSharp主页()上立即显示:

//执行请求
resresponse response=client.Execute(请求);

var content=response.content;//原始内容为字符串我通过查找


请提供更多详细信息和代码示例。完成。更新的帖子…这是来自服务器的响应。不是客户寄来的我知道了。request.Parameters.Where(p=>p.Type==ParameterType.RequestBody).FirstOrDefault();这仅获取对象,而不是序列化字符串,至少在版本
106.11.7
中是这样。
// execute the request
RestResponse response = client.Execute(request);
var content = response.Content; // raw content as string <~~~~~~~~~~
request.Parameters.Where(p => p.Type == ParameterType.RequestBody).FirstOrDefault();