C# DotNetOpenAuth消费者发布大数据&引用;Uri字符串太长";
相关报道:和-但这两个都不能令人满意地回答我的问题 我们正在使用DotNetOpenAuth将数据发布到。我们正试图在C# DotNetOpenAuth消费者发布大数据&引用;Uri字符串太长";,c#,dotnetopenauth,C#,Dotnetopenauth,相关报道:和-但这两个都不能令人满意地回答我的问题 我们正在使用DotNetOpenAuth将数据发布到。我们正试图在requestBody中发布一个77Kb的XML字符串: Dictionary<string, string> additionalParams = new Dictionary<string, string>(); additionalParams.Add("xml",requestBody); var endpoint = new MessageRe
requestBody
中发布一个77Kb的XML字符串:
Dictionary<string, string> additionalParams = new Dictionary<string, string>();
additionalParams.Add("xml",requestBody);
var endpoint = new MessageReceivingEndpoint(requestURL, HttpDeliveryMethods.PostRequest | HttpDeliveryMethods.AuthorizationHeaderRequest);
HttpWebRequest request = XeroConsumer.PrepareAuthorizedRequest(endpoint, accessToken, additionalParams);
WebResponse response = request.GetResponse();
string thisResponse = (new StreamReader(response.GetResponseStream())).ReadToEnd();
Dictionary additionalParams=new Dictionary();
additionalParams.Add(“xml”,requestBody);
var endpoint=new messagereceivingendedpoint(requestURL,HttpDeliveryMethods.PostRequest | HttpDeliveryMethods.AuthorizationHeaderRequest);
HttpWebRequest请求=XeroConsumer.PrepareAuthorizedRequest(端点、accessToken、附加参数);
WebResponse=request.GetResponse();
字符串thisResponse=(新的StreamReader(response.GetResponseStream()).ReadToEnd();
PrepareAuthorizedRequest
正在抛出:无效URI:URI字符串太长。
有什么方法可以用DotNetOpenAuth发布“大”数据吗?。当您的参数长度超过2Kb时,此选项将中断
我已将其功能替换为我自己的低效但有效的功能:
internal static string EscapeUriDataStringRfc3986(string value)
{
StringBuilder escaped = new StringBuilder();
string validChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-._~";
foreach (char c in value)
{
if(validChars.Contains(c.ToString())){
escaped.Append(c);
} else {
escaped.Append("%" + Convert.ToByte(c).ToString("x2").ToUpper());
}
}
// Return the fully-RFC3986-escaped string.
return escaped.ToString();
}
我不明白。错误消息并不是在抱怨POST数据。如果我将
requestbody
设置为较小的值,则可以正常工作。当requestbpdy
较大时,它会给出错误。我正在通过PrepareAuthorizedRequest
-我不知道该特定函数的作用-它是由DotNetOpenAuth提供的,我还没有查看它的源代码。我假设它使用一个URI构建器,并将XML数据附加到URL的末尾。也许我应该问另一个问题——“我有一个大文件需要用OAuth发布。如何发布?”只是我不想让它看起来像是我在请别人为我做工作