[英]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.