Microsoft Graph API PUT OneDrive/SharePoint [英] Microsoft Graph API PUT OneDrive/SharePoint
问题描述
试图将文件发布到共享文档"文件夹的子文件夹中.我以为我的语法正确,但是我一直收到StatusCode 400错误请求.
Trying to post a file to a subfolder of the Shared Documents folder. I thought I had the correct syntax down, but I keep getting 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
其中文件名"是实际的文件名.
where "filename" is the actual filename.
我知道下面的GET列出了子文件夹:
I know a GET to the following lists the subfolder:
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
}}
似乎正在向我发送部分请求.
Seems like it is dropping part of the request to me.
推荐答案
首先, https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com/drives 将返回相同的结果,我们希望使用第二个结果.
First, https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com,495435b4-60c3-49b7-8f6e-1d262a120ae5,0fad9f67-35a8-4c0b-892e-113084058c0a/drives and https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com/drives will return the same results, we prefer the second one.
我从未成功运行以下API:
I have never sucessful run the following API:
/drives/{drive-id}/items/{parent-id}:/{filename}:/content
但是根据我的测试,以下API效果很好:
But based on my test, the following API works well:
/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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!