0

用例

我想使用 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 实现中是否存在错误?!?

我做错了什么?

4

0 回答 0