2014-06-08 5 views
1

AddBody 호출의 직렬화 된 결과에 액세스하는 방법을 찾고 있습니다.RestSharp 직렬화 출력을 얻습니다.

내장 된 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); 
} 
+0

자세한 내용과 코드 예를 제공해주십시오. – 1232133d2ffa

+0

완료. 업데이트 된 게시물 ... – Nikoli

답변

-1

오른쪽 RestSharp 홈페이지 오프 (http://restsharp.org/는) :

// execute the request 
RestResponse response = client.Execute(request); 
var content = response.Content; // raw content as string <~~~~~~~~~~ 
+0

이것은 서버의 응답입니다. 클라이언트가 보낸 내용이 아닙니다. – Nikoli

+0

알아 냈습니다. request.Parameters.Where (p => p.Type == ParameterType.RequestBody) .FirstOrDefault(); – Nikoli

1

나는 this post를 찾아 그것을 알아 냈다.

request.Parameters.Where(p => p.Type == ParameterType.RequestBody).FirstOrDefault(); 
관련 문제