Skip to main content
Solved

How do I create some kind of loop to retrieve all the data I need from an API?


The request URL looks like this:

https://reportapi.application.com/dashboard?from=YYYY-MM-DD&to=YYYY-MM-DD&state=XXXXXX&api-version=1.0

 

How can I create some kind of setup (or loop) where I can easily retrieve the data from an entire year per month per state? The data itself doesn't have some kind of timestamp, so I'll have to retrieve each month separately.

So for example:

2022-01-01 till 2022-01-31 for Ohio

2022-01-01 till 2022-01-31 for Florida

2022-02-01 till 2022-02-31 for Ohio

2022-02-01 till 2022-02-31 for Florida

etc...

Best answer by ebygomm

No need for a loop, if you have a start date for the year, you can clone a feature 12 times, then create start and end dates for each month based on the copynumber

e.g. for the start date for a month

@DateTimeAdd(@Value(startofyear),P@Value(_copynum)M)

Then for the end date you can add a month and minus a day to get the last day of the month

@DateTimeAdd(@DateTimeAdd(@Value(startdate),P1M),-P1D)

Then you should have everything needed to create your request url once you join in the state info

View original
Did this help you find an answer to your question?

2 replies

ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • Best Answer
  • February 7, 2023

No need for a loop, if you have a start date for the year, you can clone a feature 12 times, then create start and end dates for each month based on the copynumber

e.g. for the start date for a month

@DateTimeAdd(@Value(startofyear),P@Value(_copynum)M)

Then for the end date you can add a month and minus a day to get the last day of the month

@DateTimeAdd(@DateTimeAdd(@Value(startdate),P1M),-P1D)

Then you should have everything needed to create your request url once you join in the state info


Thank you! That's just what I needed!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings