Skip to main content
Solved

REST API: Dynamic Dates, inputs and Data Selection Rules

  • January 26, 2022
  • 9 replies
  • 275 views

Hi

This is a somewhat similar question asked by Sturla Svendsen

The API I am using only returns data when fromDate and toDate are populated in the URL params.

When setting up the Data Source (CData) I won't be able to fetch anything without these dates.

I have tried creating the datasource with hard coded dates in the Edit-window in DH and altering the RSD-file the way that Thomas Lind informed Sturla about in the post linked above.

However, when I delete the URL params in the Edit-window, and rely solely on the already created RSD-file, the connection won't work (401 as the url is invalid).

When I try to add data selction rules and execute, it states the the input fields (that are written in the api:info-secion of the RSD-file) are unknown.

I really could use an complete answer as to how to connect to an API with dynamic dates in the URL params.

The guides/documentation found on this webpage is fragmented and doesn't work with the use case above.

Thank you

 

Kenneth

Best answer by Thomas Lind

Hi Kenneth

I have since updated my RSD guide with some info about how I add a dynamic date to a RSD file.

https://legacysupport.timextender.com/hc/en-us/articles/360052383191-Creating-and-using-RSD-files-for-CData-providers#h_01F4S5NBJ6ENMBF7JA4MMMNEAM

I would start by generating the rsd with some mock dates I know will give a successful test connection. Then add the changes to that while keeping the dates as default values.

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

9 replies

Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1015 replies
  • Answer
  • January 27, 2022

Hi Kenneth

I have since updated my RSD guide with some info about how I add a dynamic date to a RSD file.

https://legacysupport.timextender.com/hc/en-us/articles/360052383191-Creating-and-using-RSD-files-for-CData-providers#h_01F4S5NBJ6ENMBF7JA4MMMNEAM

I would start by generating the rsd with some mock dates I know will give a successful test connection. Then add the changes to that while keeping the dates as default values.


  • Explorer
  • 14 replies
  • June 4, 2024
Thomas Lind wrote:

Hi Kenneth

I have since updated my RSD guide with some info about how I add a dynamic date to a RSD file.

https://legacysupport.timextender.com/hc/en-us/articles/360052383191-Creating-and-using-RSD-files-for-CData-providers#h_01F4S5NBJ6ENMBF7JA4MMMNEAM

I would start by generating the rsd with some mock dates I know will give a successful test connection. Then add the changes to that while keeping the dates as default values.

 

Hi Thomas,

I’ve managed to setup the RSD-file, however I need to make it dynamic.

I need to dynamically calculated the current UTC datetime to parse to a custom header.

 

  <api:set attr="Header:Name#"  value="utcdate" />
  <api:set attr="Header:Value#" value="2024-05-31 09:33:00" />

 

The bold part needs to be dynamically calculated. Do you have an idea how to approach that?

I couldn’t make it work using the available guide.


Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1015 replies
  • June 4, 2024

Hi @Erwins 

Is the date applied set up as yyyy-mm-dd HH:mm:ss or similar?

Does it work if you manually apply a date like you do in the example?

I have seen some dates having to use the following yyyy-MM-dd'T'HH:mm:ss.SSSz or similar.


  • Explorer
  • 14 replies
  • June 4, 2024

Hi @Thomas Lind ,

 

the date needs to be exactly as in my example. So there probably needs to be some formatting applied also when the datetime is generated dynamically. It’s also important the datetime is converted to UTC first.

 

the RSD file works with my example.


Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1015 replies
  • June 4, 2024

Hi @Erwins 

You could try this function instead of date.

[attr | utcnow([outputformat])]

Returns the current system UTC date and time.

  • outputformat: The optional format specifier. Valid specifiers include d (short date pattern), D (long date pattern), f (long date/short time pattern), F (long date/time pattern), g(general short date/time pattern), G (general short date/long time pattern), r or R (RFC1123 pattern), s (sortable date/time pattern), t (short time pattern), T (long time pattern), file (Windows file time), MM/dd/yy, etc.

 

So set up the value as utcnow()

Like 

<api:set attr="Header:Name#"  value="utcdate" />
<api:set attr="Header:Value#" value="[utcnow()]" />

 


  • Explorer
  • 14 replies
  • June 4, 2024

Hi @Thomas Lind ,

This:

  <api:set attr="Header:Name#"  value="utcdate" />
  <api:set attr="Header:Value#" value="[utcnow()]" />

 

Gave me this result:

 


Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1015 replies
  • June 5, 2024

Hi @Erwins 

I thought it would work without adding an outputformat. Try to add it with an upper case F like so.

<api:set attr="Header:Name#"  value="utcdate" />
<api:set attr="Header:Value#" value="[utcnow('F')]" />

F should be equal to long date/time pattern

Otherwise try with ‘yyyy-MM-dd HH:mm:ss’


  • Explorer
  • 14 replies
  • June 5, 2024

Hi @Thomas Lind,

 

Adding the ‘F’ returns:

 


  • Explorer
  • 14 replies
  • August 26, 2024
Erwins wrote:

Hi @Thomas Lind,

 

Adding the ‘F’ returns:

 

 

I found a solution, using arc:set does the trick.
 

<api:set attr="Header:Name#"  value="utcdate" />
<arc:set attr="Header:Value#">[_ | utcnow("yyyy-MM-dd'T'HH:mm:ss")]</arc:set>

 


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