[英]How to see json from RestRequest object?
I have RestRequest that I format to Json and add and send toSerialize which works just fine. 我有RestRequest,我将其格式化为Json并添加并发送到Serialize,效果很好。 I just want to retrieve the generated json from restRequest object. 我只想从restRequest对象检索生成的json。 How can I accomplish that? 我该怎么做? I searched inside the class and I found no way to see the body. 我在全班范围内搜寻,但没有发现尸体的方法。
thanks 谢谢
[DataContract]
public class ToSerialize
{
[DataMember]
public string somefield { get; set; }
}
var request = new RestRequest("/someresource", Method.POST);
request.RequestFormat = DataFormat.Json;
var toSerialize = new ToSerialize();
toSerialize.someField = "hey";
request.AddBody(toSerialize);
var response = client.Execute(request);
You might be looking on the wrong object. 您可能正在寻找错误的对象。
The body comes back on the response object under the property Content. 正文返回到属性Content下的响应对象。
Link to the interface: https://github.com/restsharp/RestSharp/blob/master/RestSharp/IRestResponse.cs#L38 链接到界面: https : //github.com/restsharp/RestSharp/blob/master/RestSharp/IRestResponse.cs#L38
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.