在添加我得到的参数后,我正在使用 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的消息