Skip to Content
0

PI REST Sender Adapter – Polling a REST API

Dec 12, 2016 at 10:22 PM

314

avatar image

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!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Harish Mistri Dec 12, 2016 at 11:53 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Rafael Vieira Dec 13, 2016 at 01:40 PM
0

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!

Share
10 |10000 characters needed characters left characters exceeded
Rafael Vieira Dec 14, 2016 at 03:28 AM
0

Well, I'll close this topic as there seems to have no further suggestions from the community.

Tks!

Share
10 |10000 characters needed characters left characters exceeded