Skip to main content
Solved

How to connect to REST/API endpoint with dynamic date input?


Hi,

I need to extract data from an API which take dates as input values, [from date] and [to date]. And I need to extract data from this API each day. 

Is it possible to pass dynamic dates to the API connection based on todays date? I can't figure out how to do this.

 

cheers,

Sturla

Best answer by Thomas Lind

Hi Sturla

You can use <input> fields in the RSD files to do so.
I explain how to generate RSD files here RSD
When you have the RSD file you add an extra row called input in the <api:info> section. Like this.
<input name="fromdate" xs:type="date" default="2020-01-01"/>
<input name="todate" xs:type="date" default="2021-01-01"/>

In the <app:set attr="uri" value="http://rest.api.com/Data">

You change the uri value link as so.
"http://rest.api.com/Data?FromDate=[_input.fromdate]&ToDate=[_input.todate]"

Now you will be able to use these fields in a custom data selection rule similar to this



If you want to use dynamic dates, use dynamic variables
Dynamic-project-variable

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

4 replies

Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1026 replies
  • Answer
  • January 9, 2020

Hi Sturla

You can use <input> fields in the RSD files to do so.
I explain how to generate RSD files here RSD
When you have the RSD file you add an extra row called input in the <api:info> section. Like this.
<input name="fromdate" xs:type="date" default="2020-01-01"/>
<input name="todate" xs:type="date" default="2021-01-01"/>

In the <app:set attr="uri" value="http://rest.api.com/Data">

You change the uri value link as so.
"http://rest.api.com/Data?FromDate=[_input.fromdate]&ToDate=[_input.todate]"

Now you will be able to use these fields in a custom data selection rule similar to this



If you want to use dynamic dates, use dynamic variables
Dynamic-project-variable


Thanks, much appriciated


I have tried to generate the RSD file according to your post, but no success so far. The RDS file does not appear in the folder I have added for location. I have synchronized the source, I have tried deploy&execute and sunchronizing again. I have installed the latest version of DH, and updated the Rest provider. The data loads into DH with no trouble.

Any tips for why this happens?

 


Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1026 replies
  • January 21, 2020

Start by keeping it simple. Use only the most necessary fields to make it work and do it in steps. First add an URI and synchronize, does that work.
If yes add a location by clicking on the location field and set Generate Schema Files to OnUse. If this doesn't work change the Generate Schema File to OnStart.


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