cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
asafweis
Resolver I
Resolver I

Google maps API and JSON format

Hi all,

 

I'm building a flow that sends an API request via HTTP GET to google's maps API in order to get a trip duration from one destination to another. 

 

Everything works so far, however when i get the response back  from google i get the JSON in a schema that doesn't seem to let me select the particular property that I'm after.

 

What I'm trying to isolate is the duration_in_traffic element from the JSON. Can anyone help me out with this? I've tried PARSE JSON without success.

 

Here is the output from the HTTP request:

 

{
  "destination_addresses": [
    "10 Walker St, Braeside VIC 3195, Australia"
  ],
  "origin_addresses": [
    "64 Cochranes Rd, Moorabbin VIC 3189, Australia"
  ],
  "rows": [
    {
      "elements": [
        {
          "distance": {
            "text""10.4 km",
            "value"10394
          },
          "duration": {
            "text""14 mins",
            "value"850
          },
          "duration_in_traffic": {
            "text""14 mins",
            "value"865
          },
          "status""OK"
        }
      ]
    }
  ],
  "status""OK"
}

 

How can i get the value of 14 mins?

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
efialttes
Super User
Super User

Hi!

I would try withthe following WDL expression

 

first(first(body('HTTP')?['rows'])?['elements'])?['duration']?['text']

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

3 REPLIES 3
efialttes
Super User
Super User

Hi!

I would try withthe following WDL expression

 

first(first(body('HTTP')?['rows'])?['elements'])?['duration']?['text']

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Thank you!

Worked perfectly

Muito obrigado

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (5,234)