4

取得したパラメーターを追加した後、RestClient と RestRequest を使用してリクエストを作成しています。

エラー:

Invalid URI: The URI string is too long. 

これは、データが正しく投稿されていないことに関係していると思います。私のコードは次のとおりです。

RestClient client = new RestClient();
client.BaseUrl = "URL";
client.Authenticator =
    new HttpBasicAuthenticator("api",
            "KEY");
RestRequest restRequest = new RestRequest(Method.POST);
restRequest.AddParameter("domain",
            "DOMAIN", ParameterType.UrlSegment);
restRequest.Resource = "{domain}/messages";
restRequest.AddParameter("from", (string) sender["alias"] + "<email>");
restRequest.AddParameter("to", (string)recipient["alias"] + "<" + (string)recipient["email"] + ">");
restRequest.AddParameter("subject", subject);
restRequest.AddParameter("html", body);              
var result = client.Execute(restRequest);
if (result.StatusCode != System.Net.HttpStatusCode.OK)
{
     throw new Exception(result.ErrorMessage,new Exception(result.StatusCode + " - " + result.StatusDescription));
}

body パラメーターは HTML メールであるため、非常に長くなる可能性があります。上記のエラーの原因は何ですか?

http://pastebin.com/HgbBHVpCを送信するために、コードが短い本文を使用して作成する要求を次に示します 。

送信しようとしているメッセージを含む完全なスタック トレースhttp://pastebin.com/dRhXire6

4

3 に答える 3

0

RestSharp の既知の機能のように見えます。

https://groups.google.com/forum/?fromgroups#!topic/restsharp/9b5bpK3gt9g

于 2014-07-11T04:09:09.203 に答える
0

http://msdn.microsoft.com/en-us/library/z6c2z492.aspx

ドキュメントを見ると、 uriString の長さが 65519 文字を超えています

于 2012-12-19T14:59:11.623 に答える
0

またはのrequest.AddParameter(contentTyp, ContentItself, ParameterType.RequestBody); 場合がありrequest.AddBodyます。また、フィドラーなどを使用して、実際に送信したリクエスト (url\body) を確認してみてください。

于 2012-12-19T15:28:23.247 に答える