简体   繁体   English

无法从 C# 和图形资源管理器中的 Sharepoint 图形获取驱动器项目和驱动器文件夹

[英]Failing to getting Drive items and Drive Folders from Sharepoint Graph in C# and Graph Explorer

I'm having some problems with the Graph Drive items.我在使用 Graph Drive 项目时遇到了一些问题。 I'm trying to access a file with a certain structure to read, write and update files in a folder.我正在尝试访问具有特定结构的文件以读取、写入和更新文件夹中的文件。 Thing is that I can't access the lead folder map, I've tried different possibilities in C# and Graph Explorer.问题是我无法访问主要文件夹 map,我在 C# 和 Graph Explorer 中尝试了不同的可能性。


The folder structure ► MySite.sharepoint.com ► MyUnderSite ► MainDriveFlder ► CustomerDriveFolder ► Driveitems文件夹结构 ► MySite.sharepoint.com ► MyUnderSite ► MainDriveFlder ► CustomerDriveFolder ► Driveitems

and

MySite ► MyUnderSite ► MainDriveFlder ► DriveItems MySite ► MyUnderSite ► MainDriveFlder ► DriveItems

MySite = Sites/CustomerSitename.sharepoint.com: MySite = 站点/CustomerSitename.sharepoint.com:
MyUnderSite = Sites/CustomerSitename.sharepoint.com:/sites/CustomerSitename2: MyUnderSite = 站点/CustomerSitename.sharepoint.com:/sites/CustomerSitename2:
MainDriveFlder = Customer_Files MainDriveFlder = Customer_Files
CustomerDriveFolder = CustomerNr1_Files CustomerDriveFolder = CustomerNr1_Files
Driveitems = word.docs or pic.png or exel.xlsx Driveitems = word.docs 或 pic.png 或 exel.xlsx


What i tried我试过的

In C#在 C#

graphserviceClient.Sites["MySite.sharepoint.com:/sites/MyUnderSite:"].Drives.Request().GetAsync();
graphserviceClient.Sites["MySite.sharepoint.com:/sites/MyUnderSite:"].Drives[""].Request().GetAsync();

https://graph.microsoft.com/v1.0/drives/ {drive-id}/root/children https://graph.microsoft.com/v1.0/drives/ {drive-id}/root/children

graphserviceClient.Sites["MySite.sharepoint.com:/sites/MyUnderSite:"].Drives["Customer_Files"].Root.Children.Request().GetAsync();

https://graph.microsoft.com/v1.0/sites/ {tenant}.sharepoint.com:{path-to-site(ie: /sites/HR)}:/drives https://graph.microsoft.com/v1.0/sites/ {tenant}.sharepoint.com:{path-to-sites)}//sites/

graphserviceClient.Sites["MySite.sharepoint.com:/sites/MyUnderSite:"].Drives.Request().GetAsync();

https://graph.microsoft.com/v1.0/drives/ {drive-id}/root:/{folder-name}/{file-name.txt}:/content https://graph.microsoft.com/v1.0/drives/ {drive-id}/root:/{folder-name}/{file-name.txt}:/content

graphserviceClient.Sites["MySite.sharepoint.com:/sites/MyUnderSite:"].Drives["Customer_Files"].Items["ID"].Request().GetAsync();

https://graph.microsoft.com/v1.0/drives/ {drive-id}/root:/{folder-name}:/children https://graph.microsoft.com/v1.0/me/drive/root/children https://graph.microsoft.com/v1.0/drives/ {drive-id}/root:/{folder-name}:/children https://graph.microsoft.com/v1.0/me/drive /根/孩子

Graph Explorer This works i get a response https://graph.microsoft.com/v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives Graph Explorer这工作我得到一个响应https://graph.microsoft.com/v1.0/sites/MySite.sharepoint.com/sdrive:/sites:/

Then, I get a response with a filename = "name": "Customer_Files", that is a "driveType": "documentLibrary"然后,我得到一个文件名 = "name": "Customer_Files" 的响应,即 "driveType": "documentLibrary"

But when I go further into this folder or want to call items from it, I can't access them, C# same issue.但是当我 go 进一步进入此文件夹或想从中调用项目时,我无法访问它们,C# 同样的问题。 I've tried all these and no response from errors though no right URL specification.(part what i tried)我已经尝试了所有这些并且没有对错误做出响应,尽管没有正确的 URL 规范。(我尝试过的部分)

GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/items/Testfiledrive
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/items/customer_files
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/items/customer
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/items/Customer
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer_Files
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/'Customer_Files'
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/"Customer_Files"
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/{Customer_Files}
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer_Files:
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer_Files
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer:
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer_Files Export
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/root
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/root/search(q='Customer_Files')
GET /v1.0/me/drive/root/search(q='Customer_files')
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/special/documents
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Documents
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/Documents
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/Documents
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/Shared%20Documents
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Shared%20Documents
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer_Files:/root/children
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer_Files/root/children
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/items/Customer_files/children
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/items/Customer_files
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer_files/items
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer_files:
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/root
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/b!iDg2xo9-yUSnkkcTcFXBP_aUL9EMu9JIqr1aGCz8KH9m3E7rhgkqRLyqeK93F96_
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer_Files:
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives/Customer_Files
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drives
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/root
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/list
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/items
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/items/
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/items/Customer_Files
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:/drive/items
GET /v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite:
GET /v1.0/me/drive/root/children
GET /v1.0/me/drives/Customer_files

So the main problem is that i cant access or call the files in Customer_Files and in the Customer_Files/Customernr1_Files.所以主要问题是我无法访问或调用 Customer_Files 和 Customer_Files/Customernr1_Files 中的文件。

Can someone help me in finding the right structure in c# and graph explorer.有人可以帮我在 c# 和图形浏览器中找到正确的结构吗? To access these files.访问这些文件。 If i provided the wrong or to less information let me know.如果我提供的信息有误或信息较少,请告诉我。 I've been searching for weeks.我已经找了好几个星期了。

I cant give all the information and change some code names to protect the costumer.我无法提供所有信息并更改一些代号以保护客户。

Based on your structure, I can't tell whether your "MyUnderSite" is a subsite of "MySite" or another site collection.根据您的结构,我无法判断您的“MyUnderSite”是“MySite”的子网站还是其他网站集。

I will analyze both cases.我将分析这两种情况。

"MyUnderSite" is a site collection: “MyUnderSite”是一个网站集:

  1. Call GET https://graph.microsoft.com/v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite to get the id of "MyUnderSite".调用GET https://graph.microsoft.com/v1.0/sites/MySite.sharepoint.com:/sites/MyUnderSite到“获取”。
  2. Call GET https://graph.microsoft.com/v1.0/sites/{id of "MyUnderSite"}/drive/root:/customer_files .调用GET https://graph.microsoft.com/v1.0/sites/{id of "MyUnderSite"}/drive/root:/customer_files

"MyUnderSite" is a subsite: “MyUnderSite”是一个子网站:

  1. Call GET https://graph.microsoft.com/v1.0/sites/MySite.sharepoint.com/sites to list the subsites and find the id of "MyUnderSite".调用GET https://graph.microsoft.com/v1.0/sites/MySite.sharepoint.com/sites列出子站点并找到“MyUnderSite”的 id。

  2. Call GET https://graph.microsoft.com/v1.0/sites/{id of "MyUnderSite"}/drive/root:/customer_files .调用GET https://graph.microsoft.com/v1.0/sites/{id of "MyUnderSite"}/drive/root:/customer_files

Solution解决方案

var returnitem = await graphserviceClient.Sites["Site-ID"].Drives["Dive-ID"].Root.Children.Request().GetAsync();//gets all Children in the drive

var returnitemfiles = await graphserviceClient.Sites["Site-ID"].Drives["Drive-ID"].Items["File-ID"].Children.Request().GetAsync();//gets one Child and returns all the Children of that file

var returnitemfile = await graphserviceClient.Sites["Site-ID"].Drives["Dive-ID"].Items["File-ID"].ItemWithPath(fileBase.FileName).Content.Request().PutAsync<DriveItem>(fileBase.InputStream);//upload a file to the drive in a folder by id only usable for small files under 4 MB

Site-ID can look somthing like this = "c6669213-7e4f-44c9-a792-65737055c13f"站点 ID 可能看起来像这样 = "c6669213-7e4f-44c9-a792-65737055c13f"

Dive-ID ="b!iDh2xo8-yUSnkkcTcFXBP_aUL5EMu9JIqr1aGCz2KH9m3E7rhgkqRLyqiK93Z96_"潜水 ID ="b!iDh2xo8-yUSnkkcTcFXBP_aUL5EMu9JIqr1aGCz2KH9m3E7rhgkqRLyqiK93Z96_"

Folder-ID = "01BPZAU2WZBX5ZT55GHTCYVV3WZERIWJM6"文件夹 ID = "01BPZAU2WZBX5ZT55GHTCYVV3WZERIWJM6"

FileBase i used HttpPostedFileBase FileBase 我使用了 HttpPostedFileBase

暂无
暂无

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

相关问题 使用.NET SDK按路径获取Microsoft Graph Drive项目 - Getting Microsoft Graph Drive items by path using the .NET SDK 从 Microsoft Graph API 获取驱动器的项目:请求格式错误或不正确 - Getting the drive's items from Microsoft Graph API: The request is malformed or incorrect Microsoft Graph,上传到共享点驱动器:调用方未通过身份验证 - Microsoft Graph, upload to sharepoint drive: The caller is not authenticated 在Graph Explorer中无法从ac#控制台应用程序获取团队详细信息 - Failing to get Team details from a c# console app while it works from Graph Explorer 如何使用 MS GRAPH SDK C# 获取驱动器信息(ParentReference)以将文件复制到另一个驱动器 - How to get Drive infos(ParentReference) to copy file to another drive using MS GRAPH SDK C# Microsoft Graph API - 获取 Sharepoint 文档库中的项目列表时超时 (C# ASP DotNet) - Microsoft Graph API - Timeout while getting list of items in Sharepoint Document Library (C# ASP DotNet) C#“注入”驱动器到 Windows 资源管理器 - C# “Inject” drive to Windows explorer 使用图形 SDK 在 Sharepoint 驱动器的特定目录中创建文件夹 - Create a Folder in Specific Directory in Sharepoint Drive using Graph SDK Microsoft Graph:在 SharePoint 驱动器上搜索 DriveItems 未返回任何结果 - Microsoft Graph: Search for DriveItems on a SharePoint drive returns no results Microsoft Graph API ASP.NET MVC 获取驱动器项目 - Microsoft Graph API ASP.NET MVC Get Drive Items
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM