【问题标题】:RestSharp.Portable inner exception "The 'Content-Length' header must be modified"RestSharp.Portable 内部异常“必须修改‘Content-Length’标头”
【发布时间】:2017-03-06 04:09:32
【问题描述】:

我正在尝试将 RestShart.Portable 用于 xamarin 跨平台移动应用程序。对于 Windows .net 应用程序,我在 RestSharp 中使用了下面的代码,它工作正常。但是,一旦在 RestSharp.Portable 中使用与 RestSharp.Portable.WebRequest 相同的代码,我就会得到以下内部异常: “必须使用适当的属性或方法修改‘Content-Length’标头。 参数名称:名称"

我花了很多时间挖掘,但没有取得任何进展。我将非常感谢任何帮助。这是我的测试代码:

var request = new RestRequest ("MyResource", Method.POST);
string postData = myJsonToPost;
request.AddParameter("application/json; charset=utf-8", postData, ParameterType.RequestBody);
Task task;
try
{
    task = restClient.Execute(request);
    task.Wait();
    IRestResponse response = task.Result;
}
catch (Exception ex)
{
}

【问题讨论】:

    标签: c# xamarin.android portable-class-library restsharp


    【解决方案1】:

    这是 RestSharp.Portable 中的一个错误,现已修复。更多详情在这里:https://github.com/FubarDevelopment/restsharp.portable/issues/95

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-25
      • 2012-06-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多