使用REST API上载文件时出错, [英] Error When Uploading Files using REST API,
问题描述
我正在尝试使用REST API将文件上传到SkyDrive,基于此页面中的示例:
http://msdn.microsoft.com/pt-br/library/live/hh826531。 aspx#uploaded_files
我成功了,但只有当我的文件是纯文本时(即内容上没有特殊的字符)。
如果我尝试上传二进制文件,例如 PDF , ZIP ,无论如何,我总是会遇到此错误:
$
{
""error":{
    "code":"request_body_invalid",
    " message":"多部分表单数据POST的请求实体主体无效。预期格式为:\\\
\ u000a - [boundary] \\\
\ u000aContent-Dis-data;命名= \" file\英寸; filename = \" [FileName] \" \\\
\ u000aContent-Type:
application / octet-stream \\\
\ u000a [CR] [LF] \\\
\\\
[文件内容] \\\
\ u000a - [边界] - [CR] [LF]"
}
}
这是我的POST正文:
我是什么我不见了?
您是否可以尝试使用PUT?
Hi,
I'm trying to upload files into SkyDrive with REST API, based on samples from this page:
http://msdn.microsoft.com/pt-br/library/live/hh826531.aspx#uploading_files
I succeed to do it, but only when my files are plain text (ie, have no special chars on its contents).
If I try to upload a binary file, like PDF, ZIP, whatever, I always end up with this error:
{
"error": {
"code": "request_body_invalid",
"message": "The request entity body for multipart form-data POST isn't valid. The expected format is:\u000d\u000a--[boundary]\u000d\u000aContent-Dis-data; name=\"file\"; filename=\"[FileName]\"\u000d\u000aContent-Type:
application/octet-stream\u000d\u000a[CR][LF]\u000d\u000a[file contents]\u000d\u000a--[boundary]--[CR][LF]"
}
}
Here is my POST body:
What I am missing?
Is it possible for you to try using PUT instead?
这篇关于使用REST API上载文件时出错,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!