从 Web API 使用 JavaScript 在 Power Apps 门户中查询 (HTTP GET) 数据

Query (HTTP GET) data in Power Apps Portal from Web API with JavaScript

我有一个“入门门户”Power App 门户。我想利用 JavaScript 和 Web API 来查询数据。 Documentation 个州

You can use the Web API to perform create, update, and delete operations across all Microsoft Dataverse tables from your portal pages.

此外 documentation 仅列出了 CREATE、UPDATE、DELETE 操作,并且此 API 可访问为

[Portal URI]/_api

而且我已经找到了如何使用辅助方法成功进行身份验证以获得 header:

的令牌
shell.getTokenDeferred().done(function (token) { ...}

这允许在用户登录门户时进行身份验证,因此我相信所有相关的 Table 权限等都已应用。

但是,我想检索 数据 (HTTP GET)。我知道这是 possible from the Dataverse Web API.。这个 api 暴露为

[Organization URI]/api/data/v9.1/

这些真的是一样的吗API,只是以不同的方式暴露了门户?是否可以像以前的操作一样使用 GET 端点或第二个 API 作为 Portal Contact 用户进行身份验证?

相同 API 但权限不同,您需要在 _api 端点内启用要访问的表。

您可以在此页面阅读更多信息:https://docs.microsoft.com/en-us/powerapps/maker/portals/read-operations, there is also an XrmToolBox tool to assist you in this operation (but I didn't try it) https://www.xrmtoolbox.com/plugins/PowerPortalWebAPIHelper/

关于 Web API 调用,我发布了一个新工具来创建它们(类似于 CRM REST Builder)我还添加了“门户”语法(处于预览状态)但生成的 url 是相同的. Link: https://github.com/GuidoPreite/DRB