微软图形API PUT OneDrive /的SharePoint(Microsoft Graph

2019-11-05 04:15发布

尝试将文件发布到Shared Documents文件夹的子文件夹。 我原本以为正确的语法了,但我不断收到的StatusCode 400错误的请求。

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

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

我知道一个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
}}

好像它正在下降请求我的一部分。

Answer 1:

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

我从来没有SUCESSFUL运行下列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


文章来源: Microsoft Graph API PUT OneDrive/SharePoint