Skip to Content
Technical Articles

PI REST Adapter – Polling a REST API

This blog is part of a collection of blog entries that shows architectural concepts and configuration of the SAP PI REST Adapter. We also added some sample scenarios to make it easier for you to understand how your scenario can be implemented using the PI REST Adapter.

If you haven’t done so far, best is to start with the very first blog PI Rest Adapter – Don’t be afraid within the blog series covering the concepts of the REST adapter. A complete list of all blog entries can be accessed from here PI REST Adapter – Blog Overview.

The current blog describes how to poll a REST API. The sender REST adapter in polling mode has been supported since release 7.31 SP16 / 7.4 SP11.


We would like to frequently poll video information from Google’s Youtube REST API, and store the same on a file system. Furthermore, the resultset should be split into individual messages per video ID, and already polled results should be discarded.

In the SAP Process Integration Designer perspective of the NetWeaver Developer Studio (NWDS), I have defined an Integration Flow with a REST sender channel and a file receiver adapter.

01 iflow.png

Let’s focus on the configuration of the sender channel.

Configuring the REST sender channel

Double-click on the sender adapter to open the channel editor. Select the REST adapter type, and from the Message Protocol drop down menu the entry REST Polling.

02 Adapter type.png

Option 1: Incremental request based on timestamp of last call

In order to better understand the configuration below, let’s take a look at a sample response in JSON format. The REST API returns an array of items each having a unique ID stored in the etag field.

05 sample json response.png

First switch to sub-tab Data Format below tab Adapter-Specific.

The format is JSON, so select JSON from the Data type drop down menu. We would like to convert the JSON into XML, so select the Convert JSON to XML check box, and add a wrapper element to ensure that the converted XML format contains one root element only.

As mentioned below, the message should be split into individual messages per video ID. Select Split Result into Multiple Messages check box. As Array Containing Messages maintain items (See message format above).

Furthermore, duplicates should be removed. Select the Filter out Duplicates check box, and maintain etag as Unique ID Element (See message format above).

To place incremental requests, we would like to use the timestamp of the latest call. The value is stored between the calls and can be used in the REST URL as a placeholder with name incrementalToken. By the way, alternatively you can also use an XPath expression or a JSON element from the response of the last call such as next Page indicator or similar (shown below). From the Incremental Type drop down select entry Timestamp of Last Call. The timestamp format of the API complies with ISO 8601, and needs to be specified as follows: yyyy-MM-ddTHH:mm:ssZ with T and Z being constants. The REST adapter follows the Joda time format, see DateTimeFormat (Joda time 2.2 API). So, we need to place the constants in quotes. Maintain the Timestamp Format attribute as yyyy-MM-dd’T’HH:mm:ss’Z’, and define an initial value that complies with the format.

04 data format.png

Switch to tab HTTP Request, and maintain the Target URL as follows:<your API key>&part=id&q=SAP&maxResults=50&order=date&publishedAfter={incrementalToken}. Note, I added the placeholder incrementalToken in curly brackets which holds the timestamp of the last call. As HTTP Operation select GET. Finally, define a polling interval, here 3600 seconds.

03 http request.png

Option 2: Incremental request based on response content

As another option I would like to show you how to configure the incremental request in case that many pages need to be requested. As you can see below, in the response two additional elements are added holding the previous (prevPageToken) and the next page token (nextPageToken). Latter can be used in the URL to gather the next response page.

01 Chrome.png

From the Incremental Type drop down select the entry Response Content, and maintain the incremental token element as nextPageToken. This will store the value of the nextPageToken element into the placeholder incrementalToken.

From release 7.31 SP17 / 7.4 SP12 / 7.5 SP01 onwards, you can define an action in case that the very last page has been reached and hence the nextPageToken element is missing. You have the following options:

  • treat as error which is the default
  • skip current poll and retry later
  • use an empty token value
  • use the initial token value
  • use a custom token value

Here, we chose the option Use Empty Value for Token.

02 Config.png

On tab HTTP Request, maintain the Target URL as follows:<your API key>&part=id&q=SAP&maxResults=5&pageToken={incrementalToken}. Note, I added the placeholder incrementalToken in curly brackets which holds the token of the next page.

03 Config.png

I hope this blog was helpful to understand how to configure the REST sender channel in polling mode. If you like to learn more, check out the other blogs in the series, accessible from the main blog PI REST Adapter – Blog Overview.

You must be Logged on to comment or reply to a post.
  • Hello Alex,

    I am using this URL to call REST webserive using Rest Sender poll adatper

    url: https://tools-dev:9307/ceres/data/basic?lastChangedTime={incrementalToken}

    In the Incremental Request tab


    If I used Time stamp format  is this way yyyy-MM-dd'T'HH:mm:ss'%2B02:00' then only PI retrieved latest changes from REST service.

    If I used Time stamp format is this way yyyy-MM-dd'T'HH:mm:ss'Z', PI doesn't receive changes from REST webservice

    Currently CET time is 2 hours ahead into UTC time, after october this year again CET will be changed and at that only 1 hour ahead into UTC time. If that is the case I need to change a communication channel twice a year.

    My complain is I do not want change the communication channel twice a year, can you please give me some idea, how I can put permanent Time Stamp format in the Incremental Requests?

    Please suggest me.

    Thank you


  • Hi Alex,

    Polling is a great feature within REST Sender adapter. However there appears some issue with HTTP header parameters. Though we have set the parameter. REST sender adapter is not passing that to the remote system. We are trying to pass some system specific information and the call is failing because the header parameters is not passed.

    Is this is a known issue? Are there any workaround or any patch available. We are currently on the latest SP 11.

    I appreciate any response from you.



    • Hi Pradeep,

      did your problem got solved, as we are also facing issue with rest sender polling  with adding custom header to be passed with request message.



      • Hi Ashutosh, Pradeep,

        this was a bug and should be solved with the latest patch, if you are on the latest patch and still face the issue, please raise an incident ticket


        • Hi Alex,

          Passing own Header variables with the polling request seems to work now. According to the documentation, response header variables from the REST Sender with polling should also be available as XI-Headers (similar to the receiver channel). I have tested this on two 7.5 systems with current SPs and this does not seem to be the case. There are no XI headers present inside the rest namespace from the sender channel with polling.

          Is there a fix for this already? I have not found one when browsing the notes.

  • Thanks Alex,

    It is was a bug and i had opened a incident ticket and it is resolved in following note.

    29.10.2015 - 10:34:30 EST - Reply by SAP

    The issue is corrected for 7.40 SP11 with SAP Note 2202836 #REST
    Poller channel ignores custom headers#


    We did apply this note and it has indeed fixed the issue.


  • I had below queries on the REST Polling adapter :

    1. How do you view the runtime target HTTP URL, do you see in audit logs, I didn't find that. So if I use {IncrementalToken} with Last datetimestamp, I would like to see what value gets replaced in the token each time the interface runs. If the call errors out I can see the error URL but not when it is a success I can't see the URL

    2. In " Timestamp of last call " there is a field for Initial value, when does this get into effect. The first time we run this interface ? Say I am stopping this channel and again restarting it, then what time it takes for " Timestamp of last call " or does it take the initial value which I mention in configuration?

    3. There is an option of MessageSpilt - Split Result into Multiple Messages, here I can specify the xpath of the element or table which iterates. So how does this spilt happen, does it slit say I have 5000 records into batches of 50 or it is 5000 single records ?

  • Hi Alex,

    Is there any custom way of handling below HTTP polling scenario. I am trying to get candidates from a Recruiting system and I need to pass below values in URL:<key>&sc=<secret>&format=json &start=1&count=50&datestart=2014-01-01&dateend=2014-07-01

    1. So my variables are "start" which would the next starting index i.e. 1...51...101

    2. datestart would be the last time I ran this interface

    3. dateend would be current time.

    I tried the incrementalcount approach but how do I handle current date also how do I handle both incremental date and nextPageToken ?

    Thanks in advance


  • Hello,

    we have PO 7.4 SP12 and the Rest Polling Protocol is not able to choose in the Communication Channel.

    Do you have any Idea?

    Thanks and regards,


  • Hi,

    We have the same issue as Fabian with same PI version 7.40 and SP12. The 'REST Polling' Message Protocol is missing in the sender adapter.

    Does anybody know if this feature is still supported with 7.40 SP12?



  • Hi,

    I want to poll yesterdays performance data from our PO using the performancedataqueryservlet. I’m passing in the central adapter engine as component. In addition to that I need to specify a begin and end parameter. The request URL looks as follows:


    I wanted to use the incremental timestamp but only one timestamp is supported. Is there any solution to this problem?

  • Hi,

    I need to call an URL as follow:

    Begin and End date must be the same so the service would return the list of vehicles for that particular day, only.
    But Begin/End Date must be automatically incremented in each day, always to get the current day's vehicle list.

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


    • Hi Rafael,

      have you resolved your problem?

      Anyway, the URL of my scenario does not work with yyyy-MM-dd'T'HH:mm:ss'Z', but just yyyy-MM-dd.

      Do you know how to get it?

      Thanks and regards



  • I am getting an error while Polling rest APi like unsupported Media type. in below service

  • Hello,

    Please help to resolve below issue.

    Scenario = REST Webservice --> PO --> ECC

    I have configured Sender REST Polling Adapter. Every 30 minutes this adapter starts polling sales order from REST Service. I have selected parameter "Filter out duplicates". So every time it polls it picks up only unique sales order. From morning it works fine but suddenly at 4:30 PM poll time it picks up all the sales order irrespective of duplicates.

    Please help to resolve this issue as this is a production issue.


    Dheeraj kumar

  • Hi Alex,

    How can I manage the Incremental Content, when you have a Query in the URL?.


    Original URL: Id, Name,  from Product2&nextRecordsUrl={incrementalToken}


    Response 1:

    “nextRecordsUrl”: “/services/data/v43.0/query/01g2900000c6HnhAAE-2000”


    Expected Response 2:

    “nextRecordsUrl”: “/services/data/v43.0/query/01g2900000c6HnhAAE-4000”


    And so on.


    The next execution should be like:

    At the moment I have been unable to make it work. I’m doing tests with:

    Incremental Type: Response Content

    Incremental ID Element: nextRecordsUrl

    Action for Missing or Empty Token: Use Initial Value for Token

    Value: 0


    With this, the channel always retrieves information for the first batch as the ID of the "nextRecordsUrl" changes on each execution instead of being maintain.



    1st time is  "01g2900000c6HnhAAE-2000”

    2nd time is "01gK0000011AgxaIAC-2000” (the ID Changed)

    and so on...


    Please advice ?


    Thanks and Best Regards,


    • Hi Alex,


      I got it working for two consecutives executions, nevertheless, its always failing on the third one….


      The current settings are:

      Tab HTTP Request

      Target URL:{incrementalToken}


      Tab Data Format

      Incremental Type: Response Content

      Incremental ID element: nextRecordsUrl

      Action for Missing or Empty Token: Use Initial Value for Token

      Initial Value: /services/data/v43.0/query/?q=select Id, Name, ProductCode, from Product2


      With these configuration the results were the followings:

      1st Execution


      2nd Execution


      So far it is working propertly, but when getting to the last execution the JSON do not have the field "nextRecordsUrl"

      Last Execution

      “Fatal error while proccessing inbound JSON path “nextRecordsUrl” could not be found.

      Any suggestion regarding why is always failing during the third execution will be highly appreciated.


      Thanks and Best Regards,


      • Hi Eric,

        it's actually possible to define an action if the result does not contain the expected information, here nextRecordsUrl, see


  • Hi Alex,

    question about feasibility.

    I have such scenario:

    Web service to be pooled once a day with dynamic URL, excactly this
    The date of file in the URL is dynamic and needs to be {today – 1}.
    The response file content is in CSV and needs to be passed as an IDoc to ERP

    Can this be done with REST or SOAP/Axis will be better for this?

    If this is not possible then I will mabye invoke the webservice from ERP with ABAP Proxy and use Async/Sync bridge in REST adapter.

    Thanks in advance ?

    • Hi Adam,

      I have the same requirement as yours.

      Have you got solution how to set date (current date -1) in the URL?

      Thanks and regards


      • Hi Sara,


        partialy only ;).Now I'm using REST polling sender with incremental pattern set to [today - 1] date.

        It works generally but fails on holidays when the exchange rate is not puiblished and file is not available for the adapter. This is also the case for Saturdays and Sundays but this I handle in adapter activity scheduling. So, shortly - I'm still working on that.

        My next idea is to use AXIS with some module / handler which will populate the proper date in the URL.

        But this means java coding. Sooner or later I have to solve that. Stay tunned 😉

          • Hi Bartłomiej,

            sorry for late response. I should check my inbox more often ;).
            Below is my temporary & lame solution to the “today – 1” problem.

            Upon chanel activation you have to provide the initial value = “today – 1” and thats the error prone, lame part ;).


          • Hi Adam,


            I need to pass 2 parameters in the REST URL - start_time and end_time (in the format 2020-06-16T08:00:00.000-05:00) and increment by 1 hour. How can I pass these 2 parameters in the REST Polling Sender channel?

  • Hi Alexander,

    great blog!

    Actually my scenario works well with Rest-Polling with get operation.

    Just two problems disturbing me.

    The first is the Encoding of the response, which contains a csv file in the XML payload and has codepage ISO-8859-1. The german characters in the csv file become devious. Do  you know how to set character-set of response?

    The second is the incremental timestamp. Actually my senario just needs yyyy-MM-dd. But it does not work.

    I am appreciated if you could give me any hints.




    • Hi Sara,

      I am facing a similar issue where I need to pass 2 parameters in the URL for REST Polling - start_time and end_time in the following format - YYYY-MM-DDTHH:MM:SS.000-05:00 (Ex. 2020-06-16T08:00:00.000-05:00).  Any pointers on how to pass 2 parameters in the channel would be very helpful.




  • regarding

    Option 2: Incremental request based on response content


    • Only one message is fetched per polling interval. You would expect that if the poll fetched a message then it should immediately poll again and fetch next message. It shouldn' wait poll interval. When poll fails to fetch a message it should wait poll interval.


    • In request the incremental token can only be sent as url parameter. You would like to have the possibilty to send as http header or json/xml/text in the http body.


    • In the response it would be good to have binary support and then the incremental token in http header. For performance reason we don't want incremental token in the body because it is expensive to  parse the body.


    • The regular rest without polling supports multipart attachments which is needed for polling too.



    • Maybe you want to use this service below - but the po adapter can't do it. The po adapter will only poll once fetch one event and the wait poll interval instead of fetching all events immediately. Hope sap has plans to improve the adapter.



    • When calling an azure function or logic app you need to set <SECRETKEY> in the url, example below.
      In PO the <SECRETKEY> will be visible in the gui as there is no way to mask it with **** on polling adapter. In module chain you can hide secrets using the pwd.<password> syntax but for polling adapter that doesn't work.<ID>/triggers/manual/paths/invoke?api-version=2016-10-01&sp=/triggers/manual/run&sv=1.0&sig=<SECRETKEY>&incrementalToken={incrementalToken}


    OOM Out Of Memory
    When PO reads data from an external system it should have OOM protection to not read more than X bytes. This is needed for pollig adapter, and the regular sender and receiver adapters for request and response. This setting must be per channel as the requirement is very different per scenario.
    Example decompress of a xz compressed file of size 100 MB in po can easily case OOM while a simple transport of a xz compressed file of 100 MB usually works fine.
    The sftp adapter has OOM protection on the sender adapter "maximum file size restriction" but it's missing on the http based adapters, http_aae, rest, ws_aae, soap and more adapters.
    In the webdispatcher it's possible to set max payload size but this is a global setting which isn't fine grained enough and it only works in direction sender -> po.