RestSharpを使用してWebサービスを利用しようとしています。これまでのところ、すべてが順調に進んでいます(John Sheehanとすべての貢献者に乾杯!)が、私は問題にぶつかりました。すでにシリアル化された形式で(つまり、文字列として)XMLをRestRequestの本文に挿入したいとします。これを行う簡単な方法はありますか?.AddBody()関数が舞台裏でシリアル化を実行しているように見えるので、私の文字列はに変換されてい<String />
ます。
どんな助けでも大歓迎です!
編集:私の現在のコードのサンプルが要求されました。下記参照 -
private T ExecuteRequest<T>(string resource,
RestSharp.Method httpMethod,
IEnumerable<Parameter> parameters = null,
string body = null) where T : new()
{
RestClient client = new RestClient(this.BaseURL);
RestRequest req = new RestRequest(resource, httpMethod);
// Add all parameters (and body, if applicable) to the 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;
}