Contruct a stateExtension string for HTTP Binding

Hi,

Y need to request data form URL : https://myelectricaldata.fr/rte/tempo/startDate/endDate with startDate and endDate format YYYY-mm-dd.
Is there a way to set the dates relatively to now in the channel configuration ?

Thanks

I haven’t tested this, but you could alter the channel’s configuration for stateExtension to achieve this.

Example code in jruby

format = "%Y-%m-%d"
start_date = (Time.now - 2.days).to_time.strftime(format)
end_date = (Time.now - 1.day).to_time.strftime(format)
DataItem.channel.configuration["stateExtension"] = "#{start_date)/#{end_date}"

Assuming you have the base url as https://myelectricaldata.fr/rte/tempo/

I think @jimtng has the only approach that will work. I was wondering if a transformation could be applied to the URL Extension but it doesn’t see like it will work. Without that I don’t see how it can work without changing the HTTP Thing.

I think for something like this the sendHttpGetRequest Action would be an alternative approach to changing the Thing dynamically.