OneDrive将图像上传到文件夹Rest API

时间:2016-10-20 16:58:34

标签: c# rest xamarin onedrive

我正在使用OneDrive rest apis来创建文件夹并将图像上传到该文件夹​​。我可以成功创建文件夹,但图像上传调用总是给出以下错误

  

{      "错误":{         "代码":" request_body_too_large",         " message":"请求实体主体太大。"      }   }

这是我的代码:

var uri = string.Format(" https://apis.live.net/v5.0/ {0} / files?access_token = {1}",folderData.id,authToken);

var file = new OneDriveMetaData {name = backupcontent.FileName};

var multipartContent = new MultipartContent();

multipartContent.Add(元数据);

multipartContent.Add(backupcontent.Content);

var metaData = new StringContent(JsonConvert.SerializeObject(file),Encoding.UTF8," application / json");

HttpClient.DefaultRequestHeaders.TryAddWithoutValidation(" Content-Length“,bytearraylength);

HttpClient.DefaultRequestHeaders.TryAddWithoutValidation(" Content-Type"," multipart / related; boundary = A300x“);

HttpClient.DefaultRequestHeaders.TryAddWithoutValidation(" Content-Disposition"," form-data; name = \" file \&#34 ;; filename = \"& #34; + backupcontent.FileName +" \"“);

等待BaseClient.PostAsync(uri,multipartContent);

0 个答案:

没有答案