Microsoft Graph API PUT OneDrive / SharePoint

问题描述 投票:0回答:1

尝试将文件发布到“共享文档”文件夹的子文件夹中。我以为我的语法正确,但我一直收到StatusCode 400 Bad Request。

https://graph.microsoft.com/v1.0/sites/xxxxxx.sharepoint.com,495435b4-60c3-49b7-8f6e-1d262a120ae5,0fad9f67-35a8-4c0b-892e-113084058c0a/drives/b!tDVUScNgt0mPbh0mKhIK5WefrQ-oNQtMiS4RMIQFjAqJk9Tt237bQYC9yEkyNOr6/items/01JDP7KXJ7ZSCYHUJC7BFJW2X6BTR4Z4JH:/filename.xlsx:/content

其中“filename”是实际的文件名。

我知道以下列出了子文件夹的GET:

https://graph.microsoft.com/v1.0/sites/xxxxxx.sharepoint.com,495435b4-60c3-49b7-8f6e-1d262a120ae5,0fad9f67-35a8-4c0b-892e-113084058c0a/drives/b!tDVUScNgt0mPbh0mKhIK5WefrQ-oNQtMiS4RMIQFjAqJk9Tt237bQYC9yEkyNOr6/items/01JDP7KXJ7ZSCYHUJC7BFJW2X6BTR4Z4JH

请求以:

{Method: PUT, RequestUri: 'https://graph.microsoft.com/v1.0/sites/xxxxxx.sharepoint.com,495435b4-60c3-49b7-8f6e-1d262a120ae5,0fad9f67-35a8-4c0b-892e-113084058c0a/drives/b!tDVUScNgt0mPbh0mKhIK5WefrQ-oNQtMiS4RMIQFjAqJk9Tt237bQYC9yEkyNOr6/items/01JDP7KXJ7ZSCYHUJC7BFJW2X6BTR4Z4JH:/', Version: 2.0, Content: <null>, Headers:
{
  Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub...BXS_cSg1CcZHj5Q
}}

似乎它正在向我发出部分请求。

sharepoint uwp microsoft-graph onedrive put
1个回答
0
投票

首先,https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com,495435b4-60c3-49b7-8f6e-1d262a120ae5,0fad9f67-35a8-4c0b-892e-113084058c0a/driveshttps://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com/drives将返回相同的结果,我们更喜欢第二个。

我从来没有成功运行以下API:

/drives/{drive-id}/items/{parent-id}:/{filename}:/content

但根据我的测试,以下API运行良好:

/v1.0/me/drive/root:/Test/Test1.txt:/content 

要么

/v1.0/me/drives/driveid/root:/Test/Test1.txt:/content
© www.soinside.com 2019 - 2024. All rights reserved.