Forum

Notifications
Clear all

Can Excel call an API for row level data retrieval/validation?

4 Posts
2 Users
0 Reactions
248 Views
(@kombarris)
Posts: 4
Active Member
Topic starter
 

Hi!

I would like to pass various arguments/parameters to an API based on row level cell values. For example, based on a customer’s postcode, retrieve the longitude and latitude, or based on cell value product or customer number, validate the data.

 
Some years ago, I recall using the Excel functions WEBSERVICE/ENCODEURL/FILTERXML to do this type of thing but after doing some searching, I’m struggling to find any recent tutorials showing how to use these functions. I assume that this is because Power Query has probably replaced these functions.
 
When I look at Power Query tutorials using web services, the examples are based on returning a list of data, but I want to call the API for each row I have in the spreadsheet and get validation at row level.
 
Does Power Query support this?
 
Any advice is much appreciated Smile
 
Cheers,
 
Martin
 
Posted : 06/06/2024 11:26 am
Philip Treacy
(@philipt)
Posts: 1630
Member Admin
 

Hi Martin,

Yes Power Query can do this. Create a new Custom Column and for each row call your API.

So if you have a column called Postcode, in your Custom Column code would look something like 

=Web.Contents("https://www.api.com/?postcode=" & [Postcode])

That's a very simple example and your case may be more complicated.  It depends on how you have to connect to the API, what authentication you need etc.

Another way to do this is to create a function and call the function for each row.

If you can post some more info about the API and how you have to connect to it, I can provide more help.

Further info

Getting Started with API's in Power Query • My Online Training Hub

Web.Contents - PowerQuery M | Microsoft Learn

Regards

Phil

 
Posted : 06/06/2024 10:41 pm
(@kombarris)
Posts: 4
Active Member
Topic starter
 

Hi Phil!

Many thanks for the quick reply - This is really helpful.

I'll check this out and may come back to you.

Cheers,

Martin

 
Posted : 07/06/2024 4:50 am
Philip Treacy
(@philipt)
Posts: 1630
Member Admin
 

No worries.

Phil

 
Posted : 07/06/2024 5:03 am
Share: