通过 REST 使用 Microsoft Graph 将大文件上传到 Sharepoint 站点 API
Upload large file to sharepoint site using Microsoft Graph via REST API
我正在尝试将文件上传到特定的共享点网站。在此 page 向我展示了如何将示例文件上传到用户的 onedrive。但是,就我而言,我需要上传到共享点。我正在尝试使用此端点:
POST /groups/{groupId}/drive/items/{itemId}/createUploadSession
但显示此错误响应:
{
"error": {
"code": "itemNotFound",
"message": "Item not found",
"innerError": {
"date": "2022-05-08T23:15:29",
"request-id": "ca4362ca-ff36-488c-80b1-9f82c3448cd5",
"client-request-id": "ca4362ca-ff36-488c-80b1-9f82c3448cd5"
}
}
这是 cURL:
curl --request POST \
--url https://graph.microsoft.com/v1.0/groups/{groupId}/drive/items/test.txt/createUploadSession \
--header 'Authorization: Bearer xxxx' \
--header 'Content-Type: application/json' \
--data '{
"@microsoft.graph.conflictBehavior": "rename",
"description": "description",
"fileSize": 4,
"name": "test.txt"
}'
您正在尝试调用需要 itemId
的端点,但您发送的是文件名而不是 itemId
。
POST /groups/{groupId}/drive/items/{itemId}/createUploadSession
另一种方法是指定文件的路径。 item-path
必须包含在请求正文中指定的项目的名称。
POST /groups/{groupId}/drive/root:/{item-path}:/createUploadSession
// file system path using /drive/root:/path/to/file
POST /groups/{groupId}/drive/root:/path/to/test.txt:/createUploadSession
我正在尝试将文件上传到特定的共享点网站。在此 page 向我展示了如何将示例文件上传到用户的 onedrive。但是,就我而言,我需要上传到共享点。我正在尝试使用此端点:
POST /groups/{groupId}/drive/items/{itemId}/createUploadSession
但显示此错误响应:
{
"error": {
"code": "itemNotFound",
"message": "Item not found",
"innerError": {
"date": "2022-05-08T23:15:29",
"request-id": "ca4362ca-ff36-488c-80b1-9f82c3448cd5",
"client-request-id": "ca4362ca-ff36-488c-80b1-9f82c3448cd5"
}
}
这是 cURL:
curl --request POST \
--url https://graph.microsoft.com/v1.0/groups/{groupId}/drive/items/test.txt/createUploadSession \
--header 'Authorization: Bearer xxxx' \
--header 'Content-Type: application/json' \
--data '{
"@microsoft.graph.conflictBehavior": "rename",
"description": "description",
"fileSize": 4,
"name": "test.txt"
}'
您正在尝试调用需要 itemId
的端点,但您发送的是文件名而不是 itemId
。
POST /groups/{groupId}/drive/items/{itemId}/createUploadSession
另一种方法是指定文件的路径。 item-path
必须包含在请求正文中指定的项目的名称。
POST /groups/{groupId}/drive/root:/{item-path}:/createUploadSession
// file system path using /drive/root:/path/to/file
POST /groups/{groupId}/drive/root:/path/to/test.txt:/createUploadSession