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.
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. 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.
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?


If the only reason you're using Flow is to call the API from Power Apps, then yes, there is an easier way. You can create a Custom Connector and stop using Flow altogether.
Steps:
make.powerapps.com, click Dataverse then Custom Connectors+ New custom connectorCreate from blank and name the Custom Connectorhost url (without the https://)
base url to /
Security -->No authentication on this screen and use a request header on the Definition screen
Definition -->New action then name the Summary, Description and Operation ID

Request click + Import from sampleGET, POST, etc.), enter the request URL and click Import
-You'll want to paste in an example URL that has ALL required parameters.https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&latitude=48.814963&longitude=-122.71135&maxradiuskm=50&orderby=magnitude-asc

Authorization header if neededResponse click Default then Import from sample

Import


Create connectorCode preview -->
Test -->+ New connection

Request area, this applies too
Custom Connectors, select the one you just created, then click alllll the way through to the Test screen.
Test operation
Add data and find the Custom Connector you just created

Button control and add this to the OnSelect property: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. Depending on the shape of the JSON, you may need to "climb into" the nested JSON by using dot-notation in the ClearCollect() function.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With