Microsoft Graph API呼吁某些功能

发布于 2025-01-30 18:35:47 字数 301 浏览 5 评论 0原文

我正在使用SharePoint Office 365,但Microsoft Graph API是新的。我有2个功能,即在特定位置创建一个文件夹,然后在该位置上传文件。 假设网站URL是: 'https://abcdef.sharepoint.com/sites/folder1/folder2'

因此,首先,我必须在站点内部创建Directory/Folder1/Folder2,然后需要在folder2中上传文件(也许是text.txt)。 我只需要以实现所需功能所需的后续图API调用即可。

注意:我不需要任何代码结构,只需(按顺序)所需的API调用即可。

I am using Sharepoint Office 365, but am new to Microsoft Graph APIs. I have 2 functionalities, namely create a folder at a specific location and upload a file at that location.
Suppose, the site url is:
'https://abcdef.sharepoint.com/sites/folder1/folder2'

So, first I have to create directory /folder1/folder2 inside sites, and then, need to upload a file (maybe text.txt) inside folder2.
I just need the subsequent Graph API calls which are needed to achieve the required functionality.

Note: I don't need any code structure, just the API calls required (in sequence).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

万劫不复 2025-02-06 18:35:47

您可以按照以下步骤操作:

  1. 创建文件夹1。
POST https://graph.microsoft.com/v1.0/sites/{site id}/drive/root/children

{
    "name": "folder1",
    "folder": {},
    "@microsoft.graph.conflictBehavior": "rename"
}
  1. 在文件夹中创建一个子文件夹2。
POST https://graph.microsoft.com/v1.0/sites/{site id}/drive/items/{folder1 item id}/children

{
    "name": "folder2",
    "folder": {},
    "@microsoft.graph.conflictBehavior": "rename"
}
  1. 将文件上传到文件夹2。
PUT https://graph.microsoft.com/v1.0/sites/{site id}/drive/items/{folder2 item id}:/file.txt:/content
Content-Type: text/plain

The contents of the file goes here.

请参阅:在这里

You can follow this steps:

  1. Create folder1.
POST https://graph.microsoft.com/v1.0/sites/{site id}/drive/root/children

{
    "name": "folder1",
    "folder": {},
    "@microsoft.graph.conflictBehavior": "rename"
}
  1. Create a subfolder folder2 in folder1.
POST https://graph.microsoft.com/v1.0/sites/{site id}/drive/items/{folder1 item id}/children

{
    "name": "folder2",
    "folder": {},
    "@microsoft.graph.conflictBehavior": "rename"
}
  1. Upload a file to folder2.
PUT https://graph.microsoft.com/v1.0/sites/{site id}/drive/items/{folder2 item id}:/file.txt:/content
Content-Type: text/plain

The contents of the file goes here.

Refer to: here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文