cancel
Showing results for 
Search instead for 
Did you mean: 

PI REST Sender Adapter – Polling a REST API

RafaelVieira
Active Participant
0 Kudos

Hi,

I have a scenario where I need to call a REST URL as follow:
http://<host>/rest/<service>/getVehiclesbyDateRange?key=%5Bhard_coded_key%5D&;beginDate=2016-12-09&endDate=2016-12-10

Begin and End date must be the same so the service would return the list of vehicles for that particular day, only.

Tricky part is that Begin/End Date must be automatically incremented in each day, always to get the current day’s vehicle list.

e.g:

Today (Dec 12), 12am, the REST Sender must poll:

http://<host>/rest/<service>/getVehiclesbyDateRange?key=%5Bhard_coded_key%5D&;beginDate=2016-12-12&endDate=2016-12-12

Tomorrow (Dec 13), 12am, the REST Sender must poll:

http://<host>/rest/<service>/getVehiclesbyDateRange?key=%5Bhard_coded_key%5D&;beginDate=2016-12-13&endDate=2016-12-13

...and so on.

Can anyone suggest how to achieve this in the REST Sender adapter?

I tried couple of other threads / questions like this one: PI Rest Adapter Polling a Rest API but none gave me a good idea of how to achieve this.

Tks!

Accepted Solutions (0)

Answers (2)

Answers (2)

Harish
Active Contributor

Hi Rafael,

Please check the below discussion on the dynamic date in the rest URL, you can use the dynamic value generation as given in the discussion.

https://archive.sap.com/discussions/thread/3761806

The other option is to generate the target URL from dynamic configuration (message mapping UDF). refer the below blog for dynamic configuration details

https://blogs.sap.com/2014/12/18/pi-rest-adapter-consuming-synchronous-restful-service/

regards,

Harish

RafaelVieira
Active Participant
0 Kudos

Hello Harish,

Thanks for your input but if you see, the incremental token is allowed only once in the URL, and my requirement is to have it twice - one for Begin Date and one for End Date. So it does not apply to my need.

Your last suggestion also doesn't apply since I'm polling data from a REST SENDER, so there's no mapping involved before polling the API.

Has anyone another suggestion?

Tks!