cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ericonline
Community Champion
Community Champion

Collect the "results" of a Launch()?

Hm. 
I can run the function below and get some JSON in a new browser window...:

Launch(
        "https://earthquake.usgs.gov/fdsnws/event/1/query?",
        "format","geojson",
        "starttime","2019-04-02",
        "endtime","2019-04-03",
        "latitude",Location.Latitude,
        "longitude",Location.Longitude,
        "maxradiuskm",300,
        "orderby","magnitude-asc"
    )

image.png

...but I can't collect it...

ClearCollect(
    colTest,
        Launch(
            "https://earthquake.usgs.gov/fdsnws/event/1/query?",
            "format","geojson",
            "starttime","2019-04-02",
            "endtime","2019-04-03",
            "latitude",Location.Latitude,
            "longitude",Location.Longitude,
            "maxradiuskm",300,
            "orderby","magnitude-asc"
        )
)

...just results in this Collection...

image.png

I would really like to use something like this for public API's rather than have to create a Custom Connector.

Any ideas on how to easily grab the response from this Launch() function?

Thanks!

5 REPLIES 5
CarlosFigueira
Power Apps
Power Apps

At this moment you need a custom connector to be able to consume the JSON result that is returned by that API. If you feel that it should be made as part of the PowerApps language itself, please consider creating a feature request in the PowerApps Ideas board.

Right on. Thank you Carlos.
Sure feels like it wants to be a feature 🙂
The way Launch passes key value pairs is really nice for parameterized URLs like this.

Hi @ericonline 

Perhaps you could try to do this with Flow, rather than Launch?

My initial thought would be to use an HTTP Action, similar to this.

https://flow.microsoft.com/en-us/blog/http-card-tutorial/

 

You could then use the Respond to PowerApps action to return the result to PowerApps, like @Mr-Dang-MSFT describes here. However, it would be easier than this article because you wouldn't need to translate the SQL output to JSON.

https://powerapps.microsoft.com/en-us/blog/return-an-array-from-flow-to-powerapps-response-method/

 

If this technique works, you could probably adapt it fix the other issue you mentioned with different parameters returning different schemas by using the 'branching' features of Flow.

 

 

 

 

 

ericonline
Community Champion
Community Champion

Great idea @timl !

My other buddy too is always advocating for the use of Flow rather than Custom Connectors for REST calls.

Some pros of CC's vs. Flow:

  • Ease of creating and testing Custom Connectors ON THE BACK END (in the CC Definition and Test area).
  • Everything stays within PowerApps; Don't need to "go learn Flow" and all its snafus
    • Less moving parts
    • There are some licensing concerns too around # of calls per Flow to consider as well

Some cons of CC's vs Flow:

  • Calling API's from Custom Connectors can be challenging (in a ClearCollect Function).
    • Have to deal with "Default/Internal/etc." parameter settings and weirdness
    • Table() vs. "[ ]"
    • I've noticed it can take a while for a Custom Connector change to propagate to the "Front end" of PowerApps
    • Have to disconnect/reconnect/reset ConnecTIONS, etc. to jiggle the Custom Connector when a change occurs
  • Displaying results can be very challenging because there is not a lot of control of the returned schema, nested JSON, default responses, etc.
  • Can only have 1 GET call per URL!! (Whats that about?!)
    • Users have to authenticate to multiple Connectors in these cases (boo!)

Also in Flow, you get a better view into where your call is failing. You can create "breakpoints" of sorts and peek into whats happening at various points in the call/response. 

Hm... maybe i'm talking myself into Flow here!!

That's an excellent summary of CCs vs Flow. Thanks @ericonline !

I think you're talking me into Flow too!! The only other points I can think of are:

  • Flow comes with the O365 license so unlike CC, it's more easily available for those without a Plan1/Plan2 license
  • It's possible to carry out additional filtering/transformations in Flow before returning the results to PowerApps.

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,992)