【问题标题】:Using Python with pygerrit2 Library to make API call to Gerrit From Power BI Desktop使用 Python 和 pygerrit2 库从 Power BI Desktop 对 Gerrit 进行 API 调用
【发布时间】:2019-03-27 19:09:48
【问题描述】:

我最近开始使用 Power BI。我正在尝试使用 Python 从 Gerrit Rest Api 获取数据。当我在我的机器上本地运行以下代码时,它可以正常工作。

    from requests.auth import HTTPDigestAuth
    from pygerrit2.rest import GerritRestAPI
    auth = HTTPDigestAuth('####', '##############')
    rest = GerritRestAPI(url='https://gerrit.****.com', auth=auth)
    changes = rest.get("/projects/?d")

在 Power BI 中它不会导致任何错误,但在生成的导航器窗格中没有结果。

这似乎与本论坛https://community.powerbi.com/t5/Desktop/Load-JSON-as-source-via-Python/td-p/485375中概述的问题相同

但我没有看到任何真正的解决方案。

我还有其他方法可以做到这一点吗?

【问题讨论】:

    标签: python-3.x rest powerbi gerrit


    【解决方案1】:

    我认为你必须改变:

    rest = GerritRestAPI(url='https://gerrit.****.com', auth=auth)
    

    收件人:

    rest = GerritRestAPI(url='https://gerrit.****.com/a', auth=auth)
    

    如果没有“/a”,身份验证将不起作用,您将得到一个空的项目列表。

    在 Gerrit 文档here 中查看有关身份验证的更多详细信息。

    【讨论】:

    • 不起作用。 /a/ 由 pygerrit2 库放入。正如我提到的,python 脚本在 Power Bi 之外运行良好。我得到了项目列表。
    猜你喜欢
    • 2016-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-24
    • 2021-02-04
    • 2022-10-05
    • 2019-09-06
    • 1970-01-01
    相关资源
    最近更新 更多