可恢复的上传返回上传块时未经授权 [英] Resumable upload returns Unauthorized when uploading chunk
问题描述
今天,我对通过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
在那.然后,我尝试在该网址中放入一个大块,但得到一个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.
最欢迎您提出任何建议.
Any suggestions most welcome.
编辑:
这似乎受上传文件名长度的影响:
This seems to be affected by the length of the filename to which you upload:
myfile-123100000000000000000000000.txt
成功运行
myfile-1231000000000000000000000000.txt
失败
推荐答案
这已被Microsoft确认为漏洞,并已在2017年4月29日(星期六)/星期日修复.
This was confirmed as a bug by Microsoft and fixed on Saturday 29 / Sunday 30 April 2017.
这篇关于可恢复的上传返回上传块时未经授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!