Logging the XML or JSON sent by RestSharp -


i'm using restsharp send information api. log xml i've sent api can debug later.

i this:

var request = new restrequest(resourcepath, method); request.addbody(dto); logger.log(request.content); var response = client.execute(request); 

but, actual request sent restsharp not seem exposed.

everything sent in request available in request.parameters.

to make getting request body easier created extension method:

public static class restsharpextensions {     public static string getbody(this irestrequest request)     {         var bodyparameter = request.parameters             .firstordefault(p => p.type == parametertype.requestbody);         return bodyparameter == null             ? null             : bodyparameter.value.tostring();     } } 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -