[英]How do I easily return and API response from my flow to my canvas app in Power Apps?
Looking for some assistance, I have created a flow and a canvas app in power apps that calls an API, I finally got it to work but seems there has to be an easier way to do this.为了寻求帮助,我在调用 API 的强大应用程序中创建了一个流程和一个 canvas 应用程序,我终于让它工作了,但似乎必须有一种更简单的方法来做到这一点。
In my flow I'm taking the body and parsing it to get just what I need then returning the body of that response to the canvas app.在我的流程中,我获取正文并解析它以获得我需要的内容,然后将该响应的正文返回给 canvas 应用程序。 I could bypass that step and just return the body of the Api Call step, but my main question is, it seems a little to much to have to write some regex in my function when I click the button to call my flow.
我可以绕过该步骤,只返回 Api 调用步骤的主体,但我的主要问题是,当我单击按钮调用流程时,必须在我的 function 中编写一些正则表达式似乎有点过分。
This creates the collection for me with the correct fields, but is there an easier way for the app to know my schema without having to manually define it?这会使用正确的字段为我创建集合,但是有没有更简单的方法让应用程序无需手动定义它就可以了解我的架构?
Use the new Power Platform CLI command that will automatically create a Power App from a REST API.使用新的Power Platform CLI 命令将自动从 REST API 创建 Power App。
If the only reason you're using Flow is to call the API from Power Apps, then yes, there is an easier way.如果您使用 Flow 的唯一原因是从 Power Apps 调用 API,那么是的,有一种更简单的方法。 You can create a Custom Connector and stop using Flow altogether.
您可以创建自定义连接器并完全停止使用 Flow。
Steps:脚步:
make.powerapps.com
, click Dataverse
then Custom Connectors
make.powerapps.com
中,单击Dataverse
,然后单击Custom Connectors
+ New custom connector
+ New custom connector
Create from blank
and name the Custom ConnectorCreate from blank
并将自定义连接器命名为host
url (without the https://
)host
url(没有https://
)
Security -->
Security -->
Definition -->
Definition -->
New action
then name the Summary
, Description
and Operation ID
New action
然后命名Summary
、 Description
和Operation ID
Request
click + Import from sample
Request
”下单击“ + Import from sample
”GET, POST, etc.
), enter the request URL and click Import
-You'll want to paste in an example URL that has ALL required parameters. GET, POST, etc.
),输入请求 URL 并单击“ Import
”-您需要粘贴包含所有必需参数的示例 URL。https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&latitude=48.814963&longitude=-122.71135&maxradiuskm=50&orderby=magnitude-asc
https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&latitude=48.814963&longitude=-122.71135&maxradiuskm=50&orderby=magnitude-asc
Response
click Default
then Import from sample
Response
下点击Default
然后Import from sample
Import
Import
Create connector
Create connector
Code preview -->
Code preview -->
Test -->
Test -->
+ New connection
+ New connection
Custom Connectors
, select the one you just created, then click alllll the way through to the Test
screen.Custom Connectors
select 您刚刚创建的那个,然后一直单击到Test
屏幕。Test operation
Test operation
Add data
and find the Custom Connector you just createdAdd data
并找到您刚刚创建的自定义连接器
Button
control and add this to the OnSelect
property:Button
控件并将其添加到OnSelect
属性:ClearCollect(colName,
'CustomConnectorName'.OperationID(
{
required_param1: "text",
required_param2: 1234,
required_paramN: "whatever",
}
)
)
Actual example :实际例子:
ClearCollect(colEarthquakes,
'2022-11-27_SO_CustomConnector'.GETearthquakes(
{
format: "geojson",
latitude: 48.814963,
longitude: -122.71135,
maxradiuskm: 50,
orderby: "magnitude-asc"
}
)
)
Button
control and investigate the response the Custom Connector returns.Button
控件并调查自定义连接器返回的响应。 Depending on the shape of the JSON, you may need to "climb into" the nested JSON by using dot-notation in the ClearCollect()
function.ClearCollect()
function 中使用点符号来“爬入”嵌套的 JSON。 This will get you close.这会让你接近。 If you want more, check out this video
如果你想要更多,看看这个视频
Note: Custom Connectors are a premium feature.注意:自定义连接器是一项高级功能。 All users of the app will need either a PowerApps per-user or per-app license.
该应用的所有用户都需要 PowerApps 每用户或每应用许可证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.