【问题标题】:How do I get the number of documents in a SharePoint library with Microsoft graph?如何使用 Microsoft graph 获取 SharePoint 库中的文档数?
【发布时间】:2021-12-10 14:55:09
【问题描述】:

是否可以知道组库中的项目数?

我尝试使用f'groups/{group["id"]}/drive',它会返回有关库的大量信息,但不包括文件总数。

编辑 (跟进 Popkornak 的回答)

我曾尝试使用$count 参数,但它不起作用。这是有和没有$count 的查询结果:

> print(requests.get('https://graph.microsoft.com/v1.0/groups/<group-id>/drive', 
             headers={'ConsistencyLevel': 'eventual', 'Authorization': '<...>'},
             params={'$select': 'id', '$count': 'true'}).json())
{'error': {'code': 'invalidRequest', 'message': '$count is not supported on this API. Only URLs returned by the API can be used to page.', 'innerError': {'date': '2022-01-04T16:46:32', 'request-id': '<...>', 'client-request-id': '<...>'}}}

> print(requests.get('https://graph.microsoft.com/v1.0/groups/<group-id>/drive', 
             headers={'ConsistencyLevel': 'eventual', 'Authorization': '<...>'},
             params={'$select': 'id'}).json())
{'@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#drives(id)/$entity', 'id': '<...>'}

【问题讨论】:

    标签: python sharepoint microsoft-graph-api


    【解决方案1】:

    在查询中使用$count 参数,参考微软官方文档:

    https://docs.microsoft.com/en-us/graph/query-parameters

    请记住,如果它会抛出关于不支持参数使用的错误 标题:

    Key: “consistencylevel” Value: “eventual”

    【讨论】:

    • 我试过了,但没用。我编辑了有关此失败尝试的更多详细信息的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-08
    相关资源
    最近更新 更多