cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
StephenM
Level: Powered On

Need help with HTTP call and splitting the result

hi - i have a HTTP call to get data for exchange rates. and currently it sends the body to me as an email. 

 

i want to pull out jus the exchange rates such as

1 GBP = 1.42249821 USD

1 GBP = 1.14345237 EUR

1 GBP = 1.32557023 CHF

 

can someone please help me pull just that piece out.

 

thanks

 

 

here's some screens to show you what i have so far

 

Xrate 2.JPGXrates.JPG

 

 

1 REPLY 1
Community Support Team
Community Support Team

Re: Need help with HTTP call and splitting the result

Hi @StephenM,

 

Please take a try with the steps below:

1. After your HTTP action, add an Initialize variable action, choose the type to Array, Name it to Rate, and just leave the value part blank,

2. Add an Apply to each action, under the Input part of the Apply to each, enter the following expression:

split(last(split(body('HTTP'),'</lastBuildDate>')),'</title>')

The expression above would split the whole HTML into 149 items,

Image reference:

8.PNG

 

3. Within the Apply to each, add a Append to Array Variable action, under the Name, choose Rate, Value part enter the following expression:

last(split(items('Apply_to_each'),'<title>'))

This would return the "1 GBP = 1.42249821 USD" part you wanted from each items seperated under Step 2, then we will add it into the Rate Array,

9.PNG

4. Outside the Apply to each, now the Array should contain all the needed information, but with the last elements not right, so we need to remove the last item of the Array, with the expression below :

take(variables('Rate'),sub(length(variables('Rate')),1))

 

5. Add a Select Action, under the From part, enter the Expression mentioned in step 4, under the map part, enter string "Rate", and the other part, enter expression

item()

11.PNG

 

6. After that, add Create HTML table action, use the Select output as the value input, then add the Send Email Action, set Is HTML to YES, and body to the output of HTML table Action.

12.PNG

 

7. Click save, and the results under the Email should be as below:

13.PNG

 

Regards,

Michael

 

 

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,027)