使用自定义连接器将 Microsoft Graph API 报表数据导入 Power BI

Getting Microsoft Graph API Report Data into Power BI using a custom connector

我在使用自定义连接器从 Microsoft Graph 中获取我想要的内容时遇到了一些问题。本质上,我要做的是获取 Email Activity User Detail 报告并将其转换为 Power BI 报告。

该报告的 URL 如下:

/v1.0/reports/getEmailActivityUserDetail(period='D7')

为了创建这个自定义连接器,我一直在使用 MyGraph Connector Sample 因为我不太熟悉 Power Query 的使用,也不熟悉 Graph API.

我已经创建了连接器并且可以连接到 API 和所有东西,但不是 return 我的数据,所有的查询都是它 return 我的一个字节数组我似乎无能为力。

通过查看 Fiddler 跟踪,我想要的实际数据正在沿途获取,但看起来图表 API 使用重定向 URL 到下载,我'我不确定我的 Power Query 代码是否正在处理。我认为它可能只是 return 将重定向 URL 作为字符串而不是实际数据。

此外,我的查询没有代码来处理 NextLink 如果它超过 returned 行数(我想是 200?),所以我想它不会 return 完整的数据集,一旦我让它工作。如何最好地处理这个问题?

不幸的是,我对 Power Query 还很陌生(事实上,这是我第一次接触它),所以我不确定从哪里开始进行必要的更改以获得我需要的内容。

如有任何帮助,我们将不胜感激。

Microsoft Graph API - GET Reports in Graph Explorer and Power BI问题涉及到类似的问题,尽管那是通过应用程序接口本身,它似乎无法自行获取必要的授权令牌。

编辑:感谢 Marc LaFleur 的建议,我已经设法解决了这个问题。

问题确实是我试图使用 Odata.Feed 作为来源。换行:

source = OData.Feed("https://graph.microsoft.com/v1.0/me/", null, [ ODataVersion = 4, MoreColumns = true ])

收件人:

source = Csv.Document(Web.Contents("https://graph.microsoft.com/v1.0/reports/getEmailActivityUserDetail(period='D7')"))

已解决该问题并return编辑了正确的值,没有其他更改。

Microsoft Graph 的报告不是传统的 REST 端点。他们不是 returning OData/JSON,而是 return 临时 URL 到 CSV 格式的物理文件。

来自documentation

If successful, this method returns a 302 Found response that redirects to a preauthenticated download URL for the report. That URL can be found in the Location header in the response.

从您也链接的示例来看,它似乎需要一个 OData.Feed source (source = OData.Feed). In this case, you're not getting an OData result but rather a URL to a CSV file. I believe you're looking for Csv.Document