如何在MS图形中检索DriveItems的自定义列 [英] How To Retrieve Custom Columns For DriveItems in MS Graph
问题描述
我正在尝试使用Graph API来检索Sharepoint文档库中文件的层次结构.由于文档库存储在驱动器"中(在技术上称它为OneDrive是否正确?),所以我正在使用/drives
端点来获取文件列表,如下所示:
I'm trying to use the Graph API to retrieve a hierarchy of files in a Sharepoint document library. Since document libraries are stored in "drives" (is it technically correct to call it OneDrive?), I'm using the /drives
endpoint to fetch a list of files, like this:
https://graph.microsoft.com/beta/drives/{driveid}/root/children
我想从通过Sharepoint查看这些项目时存在的一些自定义列中获取信息.使用?expand=fields
不起作用,因为fields
仅存在于/sites
端点的listItem对象中,而不存在于/drives
端点的driveItem
对象中.如果我尝试从单个driveItem获取listItem(将Graph从OneDrive遍历到Sharepoint),然后扩展字段,例如
I would like to get information from some of the custom columns that exist when viewing these items through Sharepoint. Using ?expand=fields
doesn't work because fields
only exists in listItem object of the /sites
endpoint, not in the driveItem
object of /drives
endpoint. If I try obtaining the listItem from a single driveItem (traversing the Graph from OneDrive to Sharepoint), and then expanding the fields, like
https://graph.microsoft.com/beta/drives/{driveid}/items/{driveItemId}/listItem?expand=fields
这将检索内置列(Author,DocIcon和其他一些列),但似乎未检索到自定义列.
我也尝试过从/sites
端点获取文件列表,并使用?expand=fields
将获取自定义列,但是它从每个子文件夹获取每个文件,而不是当前文件夹路径.但是我觉得这应该有它自己的问题.
this retrieves built-in columns (Author, DocIcon, and some others) but doesn't seem to retrieve the custom columns.
I've also tried getting the list of files from the /sites
endpoint, and using ?expand=fields
will get the custom columns, but it gets every file from every subfolder, rather than the current folder path. But I feel that deserves its own SO question.
是否可以从driveItems中检索自定义列信息?
Is it possible to retrieve custom column information from driveItems?
推荐答案
我做了一些测试.应该工作的是:
I did some testing. What SHOULD work is:
https://graph.microsoft.com/beta/drives/{driveid}/root/children?$select=id,MyCustomColumnName
但是,当我这样做时,它只是返回了该id字段.我认为,这是图形中的错误,因为在SharePoint REST api中确实可以使用这种类型的查询.
However, when I did that, it just returned that id field. In my opinion, that is a bug in the graph because this same type of query does work in the SharePoint REST api.
如果这有帮助,则可以使用SharePoint REST api完成此操作.您的终结点查询将类似于:
If this helps, you can accomplish this by using the SharePoint REST api. Your endpoint query would be something like:
https://{yoursite}.sharepoint.com/sites/{sitename}/_api/web/lists/(' {DocumentLibraryID}')/items?$select=id,MyCustomColumnName
还有其他方法可以执行相同的查询.
There are other ways to do the same query.
这篇关于如何在MS图形中检索DriveItems的自定义列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!