RestSharp 获取序列化输出 [英] RestSharp get serialized output
本文介绍了RestSharp 获取序列化输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种方法来访问 AddBody 调用的序列化结果.
I am looking for a way to access the serialized result of the AddBody call.
我正在使用内置的 RestSharp Serializer.示例:
I am using the built in RestSharp Serializer. Example:
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);
}
推荐答案
我通过查找 这篇文章.
request.Parameters.Where(p => p.Type == ParameterType.RequestBody).FirstOrDefault();
这篇关于RestSharp 获取序列化输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文