.net - How to add text to request body in RestSharp -
i'm trying use restsharp consume web service. far everything's gone (cheers john sheehan , contributors!) i've run snag. want insert xml body of restrequest in serialized form (i.e., string). there easy way this? appears .addbody() function conducts serialization behinds scenes, string being turned <string />
.
any appreciated!
edit: sample of current code requested. see below --
private t executerequest<t>(string resource, restsharp.method httpmethod, ienumerable<parameter> parameters = null, string body = null) t : new() { restclient client = new restclient(this.baseurl); restrequest req = new restrequest(resource, httpmethod); // add parameters (and body, if applicable) request req.addparameter("api_key", this.apikey); if (parameters != null) { foreach (parameter p in parameters) req.addparameter(p); } if (!string.isnullorempty(body)) req.addbody(body); // <-- issue here restresponse<t> resp = client.execute<t>(req); return resp.data; }
here how add plain xml string request body:
req.addparameter("text/xml", body, parametertype.requestbody)
;
Comments
Post a Comment