403 Forbidden on reading CSV file in OneDrive

荒凉一梦 提交于 2019-12-11 05:32:39

问题


I am trying to read my CSV files using Microsoft Graph API:

/me/drive/items/${someId}/workbook/worksheets('${someSheetName}')/usedRange

However it returns

403 Forbidden -> AccessDenied -> Could not get WAC token.

When reading a XLSX file, it works fine. I am using personal microsoft account.

Thanks for your help.


回答1:


CSV and .xls are not supported formats. Only .xlsx works for this feature.




回答2:


As others have pointed out, CSV files are not supported in the new Excel API. However, to help others who were initially confused by the error message like me, I'd like to elaborate a bit more.

First, it's useful to distinguish the Microsoft Graph API and the Excel API. The Microsoft Graph API mostly provides the basic functionalities of a file storage system so that third-party can work with files and folders in OneDrive and SharePoint. The Excel API, on the other hand, provides Excel functionalities so that third-parties can work with Excel files (.xlsx files specifically). Although the Excel API uses the same resource identification system and shares the same request "syntax" as the Microsoft Graph API, the two are not the same.

The request below clearly belongs to the Excel API, not the Graph API. Although the Graph API can handle CSV file (it doesn't care what type of file it's working with since it's application-agnostic), the Excel API can't.

/me/drive/items/${someId}/workbook/worksheets('${someSheetName}')/usedRange

If you look at the endpoints in the Excel API, you'll see that most of them point to features that do not exist in CSV files: workbook, worksheet, cells, etc. For instance, the request above attempts to read a specific worksheet within a workbook file, which is not possible if the file is CSV.

Also, the Excel API handles features such as formulas, data types, and cell formatting, which are also not present in CSV files.

Essentially, CSV files are no more than just plain-text files and thus are not supported by the Excel API.

Of course, it would be really helpful if the Excel API team could return a more meaningful error message. I personally find the current error message very misleading.



来源:https://stackoverflow.com/questions/50014639/403-forbidden-on-reading-csv-file-in-onedrive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!