Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Galat198
Helper IV
Helper IV

Get Range of dates in API

Hi,

I have seen some answers on the theme but still can not figure out how to solve a problem.

 

I'm trying to read data from API :

= Json.Document(Web.Contents("https://********/api/v1/*******/xxxxxx?month=2&year=2020"))

That means each API returns data  for one month

I need to replace a month and a year each time to get data for a different period.

 

I need to get a table with data from 01/2020 to the current month (that next month will be another month)

Galat198_0-1614161540097.png

 

I mean I need to somehow merge several APIs to create one table .... or there is another way.

 

I try to create a parameter, but each parameter returns a single value even if it is a parameter with a list range: the year 2020-2030, month 1-12.

 

***It must not be produced dynamically, because the Dynamic dataset I cant update on the Power BI WEB Service.

1 REPLY 1
ImkeF
Super User
Super User

Hi @Galat198 ,
moving the query parameters into the query-record should allow refresh in the service.

Json.Document(Web.Contents("https://********/api/v1/*******/xxxxxx",
[Query=[month=2, year=2020]]))


Just have in mind that the original request must be valid, so you might have to leave (some) query parameters present in the initial call (they will be replaced by the dynamic values from the Query-record later):

Json.Document(Web.Contents("https://********/api/v1/*******/xxxxxx?month=2&year=2020",
[Query=[month=<ReferenceToDynamicParameter>, year=<ReferenceToDynamicParameter>]]))

More reading here: Dynamic Web.Contents() and Power BI Refresh Errors – Data Inspirations

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors