Я проверил возможность загрузки файлов в общую папку на OneDrive, принадлежащую другому пользователю. У меня не было никаких проблем, чтобы достигнуть этого, используя GraphExplorer .
Вот что я сделал:
- Я получил список общих файлов и папок:
GET /me/drive/sharedWithMe
Возвращено (некоторые данные опущены):
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
"value": [
{
"@odata.type": "#microsoft.graph.driveItem",
"id": "<itemId>",
"name": "Folder name",
"parentReference": {
"driveId": "<myUserId>",
"driveType": "personal"
},
"remoteItem": {
"id": "<remoteItemId>",
"name": "Folder name",
"createdBy":
"user": {
"displayName": "Other user name",
"id": "<otherUserId>"
}
},
"folder": {
"childCount": 0
},
"parentReference": {
"driveId": "<otherUserId>",
"driveType": "personal"
},
"shared": {
"owner": {
"user": {
"displayName": "Other user name",
"id": "<otherUserId>"
}
}
}
}
}
]
}
- Затем я сформировал запрос PUT со следующими данными:
PUT /drives/{otherUserId}/items/{remoteItemId}:/test.txt:/content
Content-Type: text/plain
The contents of the file goes here.
Ответ: Success - Status Code 201
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('<otherUserId>')/items/$entity",
"id": "<itemId>",
"name": "test.txt",
"size": 35,
"createdBy": {
"application": {
"displayName": "Graph explorer"
},
"user": {
"displayName": "My user name",
"id": "<myUserId>"
}
},
"parentReference": {
"driveId": "<otherUserId>",
"driveType": "personal",
"id": "<parentReferenceId>",
"name": "Folder name",
"path": "/drives/<otherUserId>/items/<parentReferenceId>"
},
"file": {
"mimeType": "text/plain"
}
}
Затем при последующем запросе GET /me/drive/sharedWithMe
значение childCount папки было увеличено до 1.
Примечание:
Конечная точка \shares
позволяет GET-запросам получать доступ к общему DriveItem или коллекции общих элементов. Не позволяет создавать новые предметы.