简体   繁体   English

如何从SharePoint列表(文档库)中获取驱动器ID以上传文件?

[英]How to get a drive ID from a SharePoint List (Document Library) for uploading files?

I want to be able to upload a text document to a SharePoint List. 我希望能够将文本文档上载到SharePoint列表。 Since it is actually a Document Library, I believe I should upload files as though I am uploading to a Drive. 由于它实际上是一个文档库,我认为我应该像上载到云端硬盘一样上载文件。 I can upload a file to the site's root location. 我可以将文件上传到网站的根目录。 I can get the ID of the List I wish to upload to. 我可以获得要上传到的列表的ID。 However the Microsoft Graph API does not appear to like the ID I provide when I use that as the destination. 但是,当我将其用作目的地时,Microsoft Graph API似乎不喜欢我提供的ID。 ListItem says that ListItems are exposed as DriveItems when using a Document Library. ListItem表示使用文档库时ListItems作为DriveItems公开。 How to upload a small file to SharePoint . 如何将小文件上传到SharePoint

I have been testing with C# and GraphExplorer . 我一直在用C#和GraphExplorer进行测试。 It boils down to my endpoint being incorrect. 归结为我的端点不正确。

When using Graph Explorer, I can query for all drives with these two queries: 使用Graph Explorer时,可以使用以下两个查询来查询所有驱动器:

graph.microsoft.com/v1.0/sites/{siteid}/drives

The query displays the Drive Name I am looking for and the ID it shows is different than its list ID. 该查询显示我要查找的驱动器名称,并且显示的ID与列表ID不同。 This indicates to me that a Document Library has a separate List ID and Drive ID. 这向我表明文档库具有单独的列表ID和驱动器ID。

Status Code 201 (Created): graph.microsoft.com/v1.0/sites/{siteid}/drive/items/ root :/testplaceholder.txt:/content 状态码201(已创建):graph.microsoft.com/v1.0/sites/{siteid}/drive/items/ root :/testplaceholder.txt:/ content

Status Code 404 (Not Found): graph.microsoft.com/v1.0/sites/{siteid}/drive/items/{ listid }:/testplaceholder.txt:/content 状态码404(未找到):graph.microsoft.com/v1.0/sites/ {siteid} / drive / items / { listid }:/ testplaceholder.txt:/ content

Status Code 400 (Bad Request): graph.microsoft.com/v1.0/sites/{siteid}/drive/items/{ driveid }:/testplaceholder.txt:/content 状态码400(错误请求):graph.microsoft.com/v1.0/sites/ {siteid} / drive / items / { driveid }:/ testplaceholder.txt:/ content

Can anyone tell me where my understanding is lacking, or where I might have messed up? 谁能告诉我缺乏了解的地方,或者我可能搞砸了的地方? Sorry for the lack of code formatting, couldn't get it to work on the URL strings. 抱歉,缺少代码格式,无法在URL字符串上使用它。

ANSWER: 回答:

Using the Drive ID I found with the first query above. 使用我在上面的第一个查询中找到的驱动器ID。

graph.microsoft.com/v1.0/sites/{siteid}/drives/{driveid}/root:/testplaceholder.txt:/content graph.microsoft.com/v1.0/sites/{siteid}/drives/{driveid}/root:/testplaceholder.txt:/content

将文件上传到库的示例端点。

https://graph.microsoft.com/v1.0/sites/siteid/drives/b!zEu8xWMaOU-BdU94l2XA7SAospdkDeREgpABeq2Ahp2VZN3js8mQTq_JU5kiCSsB/root:/test.txt:/content

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将文档从Windows Store App上载到SharePoint 2013文档库 - Uploading a document from Windows Store App to a SharePoint 2013 document library 列出Sharepoint在线文档库中的所有文件 - List all files in a Sharepoint online Document Library 使用 HTTP PUT 将文件上传到 Sharepoint (WSS 3.0) 文档库 - Uploading files to Sharepoint (WSS 3.0) document library using HTTP PUT C# 从 SharePoint 2013 文档库中检索文档列表 - C# Retrieve Document List From SharePoint 2013 Document Library 上传图片到 SharePoint 文档库 C# - Uploading Image into SharePoint document library C# 如何在使用 C# 将文档作为项目上传到 SharePoint 文档库时为自定义列添加值? - How to add value to a custom column while uploading document into a SharePoint document library as an item using C#? 如何使用 List.asmx 在 SharePoint 中获取最后添加的文档 ID - How to get the Last Added Document ID in SharePoint using List.asmx 如何将文档从Sharepoint文档库返回给用户? - How do I return a document from a Sharepoint Document library to the user? 如何使用C#将文件上传到Sharepoint在线文档库 - How to upload files to sharepoint online document library using c# 枚举文档库时如何排除隐藏/系统共享点文件 - How to exclude hidden/system sharepoint files when enumerating a document library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM