上传块时可恢复上传返回未经授权 [英] Resumable upload returns Unauthorized when uploading chunk

查看:26
本文介绍了上传块时可恢复上传返回未经授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我通过 Microsoft Graph API 的 OneDrive 可恢复上传功能遇到问题,如 这里.我有以前有效的集成测试,现在失败了.

Today I have a problem with the resumable upload feature of OneDrive via the Microsoft Graph API, as described here. I have integration tests which previously worked, which now fail.

我成功调用了 createUploadSession 并获得了一个 uploadUrl 来使用.我在这里用XXX"替换了实际的标记.

I successfully call createUploadSession and get an uploadUrl to use. I've replaced actual tokens with "XXX" here.

POST https://graph.microsoft.com/V1.0/groups/273c2c33-8533-445d-ae65-4b63be296995/drive/root:/c2fa1a83-74f3-444b-9263-c9539ee3eae2.txt:/createUploadSession HTTP/1.1
Authorization: Bearer XXX

{
  "item": {
    "@microsoft.graph.conflictBehaviour": "replace"
  }
}

回复:

{
    "@odata.context": "https://graph.microsoft.com/V1.0/$metadata#microsoft.graph.uploadSession",
    "expirationDateTime": "2017-04-27T11:07:50.5650598Z",
    "nextExpectedRanges": ["0-"],
    "uploadUrl": "https://sageglodbizp.sharepoint.com/sites/SharePointTests/_api/v2.0/drive/items/01LQXPMG56Y2GOVW7725BZO354PWSELRRZ/uploadSession?guid='9d14ed72-e532-442e-94e8-70952b365527'&path='~tmp0B_c2fa1a83-74f3-444b-9263-c9539ee3eae2.txt'&overwrite=True&rename=False&access_token=XXX"
}

所以 uploadUrl 就在那里.然后,我尝试将一个块放入此 url,但得到一个 401 Unauthorized 作为响应:

So the uploadUrl is there. Then, I try to PUT a chunk to this url but get a 401 Unauthorized in response:

PUT https://sageglodbizp.sharepoint.com/sites/SharePointTests/_api/v2.0/drive/items/01LQXPMG56Y2GOVW7725BZO354PWSELRRZ/uploadSession?guid='9d14ed72-e532-442e-94e8-70952b365527'&path='~tmp0B_c2fa1a83-74f3-444b-9263-c9539ee3eae2.txt'&overwrite=True&rename=False&access_token=XXX HTTP/1.1
Authorization: Bearer XXX

回应

HTTP/1.1 401 Unauthorized

由于我使用的是 Graph API 提供的 URL,我认为这是一个错误.我将与第一个调用相同的不记名令牌传递给第二个调用(我也尝试过没有访问令牌,因为 URL 中有一个).

As I'm using the URL provided by the Graph API, I believe this to be a bug. I'm passing the same bearer token to the second call as the first (I've also tried it with no access token, given that one is in the URL).

我已经对两个不同的 Office 365 租户进行了尝试,结果都相同.

I have tried this with two different Office 365 tenants, both with the same result.

这以前有效.关于为什么这停止工作的任何想法?uploadUrl 指向我的 SharePoint 端点而不是 Graph API 是否正确?

This has previously worked. Any thoughts on why this has stopped working? Is it correct that the uploadUrl points to my SharePoint endpoint rather than the Graph API?

我还应该补充一点,直接上传到 Graph API 的不可恢复的上传工作正常.

I should also add, a non-resumable upload directly to the Graph API works fine.

欢迎提出任何建议.

编辑:

这似乎受到您上传到的文件名长度的影响:

This seems to be affected by the length of the filename to which you upload:

myfile-123100000000000000000000000.txt工作成功

myfile-1231000000000000000000000000.txt 失败

推荐答案

这已被微软确认为一个错误,并于 2017 年 4 月 29 日/星期日 30 日修复.

This was confirmed as a bug by Microsoft and fixed on Saturday 29 / Sunday 30 April 2017.

这篇关于上传块时可恢复上传返回未经授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆