Skip to main content

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

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?

 


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