OneDrive用户A与OneDrive用户B共享一个文件夹,B可以使用共享ID访问该文件夹 . 例如,使用图形资源管理器
GET https://graph.microsoft.com/v1.0/shares/{shareId}
产量
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#shares/$entity",
"id": "{shareId}",
"name": "ASharedFolder",
"owner": { ... }
}
现在,B想要将新文件上传到ASharedFolder .
读了OneDrive docs for upload我试过了
PUT https://graph.microsoft.com/v1.0/shares/{shareId}/driveItem/children:/SomeFile.txt:/content
Content-Type text/plain
some text goes here
以及
PUT https://graph.microsoft.com/v1.0/shares/{shareId}/items/{sharedItemId}:/SomeFile.txt:/content
Content-Type text/plain
some text goes here
但两者都产生“BadRequest”,“不支持的段类型......”
编辑:我现在在OneDrive Web UI中使用两个不同的浏览器为OneDrive用户A和B播放了这个场景,所以我知道这是可能的(没有先将共享文件夹添加到B自己的根目录中),但我需要一些帮助搞清楚对OneDrive REST API的正确请求 .
有人知道吗?
1 回答
我检查了将文件上传到属于另一个用户的OneDrive上的共享文件夹的可能性 . 使用GraphExplorer实现它没有任何问题 .
这是我做的:
GET /me/drive/sharedWithMe
返回(部分数据已被省略):
PUT /drives/{otherUserId}/items/{remoteItemId}:/test.txt:/content
回复:
Success - Status Code 201
然后,在随后的
GET /me/drive/sharedWithMe
请求中,文件夹的childCount的值已增加到1 .NOTE:
\shares
endpoints 仅允许GET requests访问共享的DriveItem或共享项的集合 . 它不允许创建新项目 .