python - SharePoint在线: Get site user id using Office365-REST-Python-Client library

标签 python python-3.x sharepoint-online office365api

我正在使用 SharePoint Online 并尝试使用以下 REST API 获取网站的用户 ID:

https://url/sites/list/_api/Web/siteusers#?$select=Id&$filter=substringof('|userloginname',LoginName) eq true

我尝试了很多库,但只能使用 Office365-REST-Python-Client 成功验证 SharePoint Online 。所以,想坚持使用同一个库。

我已经浏览了 GitHub 上提供的示例 here 。提供的示例仅适用于列表项。但是,我想获取网站用户的详细信息。

有人用 Office365-REST-Python-Client 这样做过吗?图书馆?

提前致谢

最佳答案

我已将此问题发布在Office365-REST-Python-Client上并且作者已经回复了答案。我只需要根据我的要求做一些改变。下面是工作代码。希望它对某人有帮助。

 client = ClientContext(url, context_auth)
 users = client.web.site_users\
                .filter("substringof('|{0}',LoginName) eq true".format('LoginName'))
 client.load(users)
 client.execute_query()
 for user in users:
      print('User : {0}, Id: {1}'.format(user.properties["Title"], user.properties["Id"]))

关于python - SharePoint在线: Get site user id using Office365-REST-Python-Client library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58504165/

相关文章:

python - 如何更改 python 3 中日期的格式?

c# - 无法在列表中创建文件夹

python - 为什么我的简单Spark应用程序运行这么慢?

python - SQLAlchemy - 计数状态为真

python - 如何使 django 全局可用

python - 将 urllib2 获取的 gzip 数据转换为 HTML

python - 在 Python 中循环遍历子文件夹并保存为 .csv

python - Mypy 不支持的类型 Type[typeVarAlias]

rest - 在PowerShell中访问枚举名称

javascript - PnP JS 使用 FieldGeolocationValue 添加项目 - SharePoint