gpt4 book ai didi

azure - OneDrive REST API : "message": "The specified item does not have content." when downloading a file

转载 作者:行者123 更新时间:2023-12-03 00:01:44 36 4
gpt4 key购买 nike

用例

我想使用 REST API 从 OneDrive 下载 Excel 工作表

文档:

建议调用此端点的文档:GET/me/drive/items/{item-id}/content

先决条件

  1. 我使用 oauth2 正确登录,所有其他方法均有效,例如“/me”、“/me/drive/recent”、“/me/drive/sharedWithMe”

  2. 授予的凭据

调用GET/me/drive/items/{item-id}/content时出现错误消息

{
"error": {
"code": "itemNotFound",
"innerError": {
"client-request-id": "aaaaaaa-aaaa-aaaa-aaaa-aaaaa",
"date": "2020-09-26T09:19:08",
"request-id": "aaaaa-aaaa-aaaa-aaa-aaa"
},
"message": "The specified item does not have content."
}
}

当我调用 GET/me/drive/items/{item-id}

时,该文件存在并包含数据

文件存在且大小:46.272 字节



{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('<a_username>%40hotmail.com')/drive/items/$entity",
"createdBy": {
"user": {
"displayName": "<a_name> ",
"id": "<a_drive_id>"
}
},
"createdDateTime": "2020-09-27T07:29:04.893Z",
"eTag": "<an_eTag>",
"fileSystemInfo": {
"lastAccessedDateTime": "2020-09-27T11:52:31Z"
},
"id": "<a_drive_id>!<a_sub_id>",
"lastModifiedBy": {
"user": {
"displayName": "<a_name> ",
"id": "<a_drive_id>"
}
},
"lastModifiedDateTime": "2020-09-27T18:46:25.073Z",
"name": "a_filename.xlsx",
"parentReference": {
"driveId": "<a_drive_id>",
"driveType": "personal"
},
"remoteItem": {
"file": {},
"fileSystemInfo": {
"lastAccessedDateTime": "2020-09-27T11:52:31Z"
},
"id": "<an_id>!7757",
"name": "a_filename.xlsx",
"parentReference": {
"driveId": "<an_id>",
"driveType": "personal"
},
"size": 46272,
"webUrl": "https://1drv.ms/u/<a_letter>!<a_web_url_id>"
},
"webUrl": "https://1drv.ms/u/<a_letter>!<a_web_url_id>"
}

结论

微软的API实现有bug吗?!?

我做错了什么?

最佳答案

首先我们需要注意的是,在api文档中,提到了:

Only driveItems with the file property can be downloaded.

因此,当我们调用 https://graph.microsoft.com/v1.0/me/drive/时,我们需要确保目标项在响应中具有属性 file项目/item_id

enter image description here

那么我们需要关注this section ,当我们成功调用下载api时,会返回302重定向

enter image description here

关于azure - OneDrive REST API : "message": "The specified item does not have content." when downloading a file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64099004/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com