简体   繁体   English

在Python上使用Microsoft Graph API分页

[英]Paging with Microsoft Graph API on Python

I have been using some microsoft code sample, to start building an app that retrieves the groups and their members( groups/$expand=members ). 我一直在使用一些Microsoft代码示例,开始构建一个检索组及其成员( groups/$expand=members )的应用程序。 Now my problem is that because there is a lot of data I of course could not get everything through just one HTTP Request, so to test if I can access to the token value of the @odata.nextLink element that is in the json file I get as response, I've been trying to print it from my python program, and it retrieves me an error because of the '@'character (when I am trying to do print(result.@odata.nextLink) ). 现在我的问题是,因为有很多数据,我当然无法仅通过一个HTTP请求获得所有信息,因此要测试我是否可以访问json文件中的@ odata.nextLink元素的令牌值。得到响应,我一直试图从我的python程序中打印它,由于'@'字符(当我尝试执行print(result。@ odata.nextLink)时),它检索到一个错误。 Maybe I am not using it correctly, so I would like to know guys for example making some arrows a html file that allows me to go back and forth, using the nextLink token. 也许我没有正确使用它,所以我想认识一些人,例如,使用nextLink令牌将一些箭头制作为html文件,允许我来回移动。

This was my attempt to print the nextLink token (As I said I'm just trying to print the token value to see if I can use it for creating a page visualization in html, with arrows and so on): 这是我尝试打印nextLink令牌的方法(正如我所说,我只是想打印令牌值,以查看是否可以使用它来创建带有箭头等的html页面可视化效果):

@APP.route('/query')
def query():
    # query = "groups?$filter=startswith(displayName,'CASS')"
    query = "groups/?$expand=members"
    result = MSGRAPH.get(query, headers=request_headers()).data

    print(result.@odata.nextLink)
    return flask.render_template('query.html',result=result, query=query)

在此处输入图片说明

This is what i want to grab: 这就是我想要抓住的东西:

在此处输入图片说明

Thanks! 谢谢!

Based on your last screen shot, @odata.nextLink is a key in a dictionary. 根据上一个屏幕截图, @odata.nextLink是字典中的键。 Try this: 尝试这个:

print(result['@odata.nextLink'])

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM