如何使用 API 将 CSV 文件上传到 Onedrive

How to upload a CSV file to Onedrive using API

我正在尝试将 CSV 文件上传到我的 Onedrive 以进行测试,但我无法弄清楚此处显示的 URL 端点末尾的 /content 是什么:https://docs.microsoft.com/en-us/onedrive/developer/rest-api/concepts/addressing-driveitems?view=odsp-graph-online

到目前为止我所拥有的是:https://graph.microsoft.com/v1.0/me/drives/root:/{folderName}/test.csv:/content

但我收到错误消息:

{
    "error": {
        "code": "BadRequest",
        "message": "Resource not found for the segment 'content'.",
        "innerError": {
            "date": "2021-07-16T16:01:42",
            "request-id": "bf4490df-5689-4016-b609-d85a3d6e8945",
            "client-request-id": "ce01693e-ce87-61d4-c23b-79a28251818c"
        }
    }
} 

这似乎是合法的,因为我没有在其中放入任何真正的内容,但我不知道如何将 csv 文件放入 URL。当我从云解决方案发出请求时,我不确定我是否可以访问它的二进制值。

您在引用 /drives(复数)时未提供驱动器 ID。

如果您想上传到默认的 OneDrive,您希望使用 /drive(单数):

PUT /me/drive/root:/{folderName}/test.txt:/content