最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Microsoft Graph API: 'ItemNotFound' Error When Accessing Excel File in OneDrive with Python in personal account

programmeradmin2浏览0评论

I am trying to read and update an Excel file stored in OneDrive using the Microsoft Graph API. However, I consistently encounter the following error: ERROR:root:Request failed: {"error":{"code":"ItemNotFound","message":"The requested resource doesn't exist.","innerError":{"code":"itemNotFound","message":"The requested resource doesn't exist.","date":"2025-01-18T22:20:58","request-id":"d908b11c-edcc-4a73-9383-2ca4328c3f4a","client-request-id":"d908b11c-edcc-4a73-9383-2ca4328c3f4a"}}}

Steps I Took

  1. I retrieved the file ID using the Microsoft Graph API's /drive/root/children endpoint.
  • File ID returned: 1555B702B0C2A00A!s86e7ed45f177405ba089286bc4cc00af
  1. I verified that the file exists in my OneDrive account and is accessible.

  2. I used the correct API endpoint to access the workbook, for example: .0/me/drive/items/1555B702B0C2A00A!s86e7ed45f177405ba089286bc4cc00af/workbook/worksheets/Sheet1/range(address='A1:B2')

  3. I ensured the Microsoft Graph permissions are correctly configured:

  • Scopes: Files.ReadWrite, offline_access, Sites.ReadWrite.All
  • I also checked that the file is synced and accessible from my OneDrive folder.

What could cause the ItemNotFound error for a file that exists and is accessible via OneDrive?

I am trying to read and update an Excel file stored in OneDrive using the Microsoft Graph API. However, I consistently encounter the following error: ERROR:root:Request failed: {"error":{"code":"ItemNotFound","message":"The requested resource doesn't exist.","innerError":{"code":"itemNotFound","message":"The requested resource doesn't exist.","date":"2025-01-18T22:20:58","request-id":"d908b11c-edcc-4a73-9383-2ca4328c3f4a","client-request-id":"d908b11c-edcc-4a73-9383-2ca4328c3f4a"}}}

Steps I Took

  1. I retrieved the file ID using the Microsoft Graph API's /drive/root/children endpoint.
  • File ID returned: 1555B702B0C2A00A!s86e7ed45f177405ba089286bc4cc00af
  1. I verified that the file exists in my OneDrive account and is accessible.

  2. I used the correct API endpoint to access the workbook, for example: https://graph.microsoft.com/v1.0/me/drive/items/1555B702B0C2A00A!s86e7ed45f177405ba089286bc4cc00af/workbook/worksheets/Sheet1/range(address='A1:B2')

  3. I ensured the Microsoft Graph permissions are correctly configured:

  • Scopes: Files.ReadWrite, offline_access, Sites.ReadWrite.All
  • I also checked that the file is synced and accessible from my OneDrive folder.

What could cause the ItemNotFound error for a file that exists and is accessible via OneDrive?

Share Improve this question edited Jan 18 at 23:49 Rui Sousa asked Jan 18 at 23:32 Rui SousaRui Sousa 571 silver badge9 bronze badges 1
  • Can you at least point out why are you down voting the question? – Rui Sousa Commented Jan 22 at 11:37
Add a comment  | 

1 Answer 1

Reset to default 0

In my case the issue was with the sheet names. I was using different sheet name with no spaces in in it when they had spaces. Please keep in mind that the message "The requested resource doesn't exist" doesn't always mean the id of the file is incorrect buy if the sheet name is incorrect it might also happen.

发布评论

评论列表(0)

  1. 暂无评论