Skip to Content

Dear All,

I have little struggled on REST adapter when fetching the data from rest web service using SAP standard REST adapter. But I have achieved on this requirement with the help from SAP document , Alexander’s Blog & SAP thread

http://help.sap.com/saphelp_nw74/helpdata/en/d4/ee3eca7baf436b996e2473c04809b4/content.htm

PI REST Adapter – Polling a REST API

Restful webservice-source

Prerequisites on this REST sender poll:

PI 7.31 SP 16 (or) PO 7.4 SP11

SAP XI AF java component should be the latest patch level 1( Available up to today) and please make sure all dependent components should be update when you update SAP XI AF.

As you know from PI 7.31 SP 14 (or) PO 7.4 SP 11, SAP has introduced standard REST features. and they keep on adding the features. the latest one is available on  PI 7.31 SP 16(or) PO 7.4 SP 11 and it contains Rest Sender Adapter poll.

This feature is exactly match with my requirement(REST API–>PI–>JDBC) when PI wants to use GET operation (for fetching data from Rest API)

My REST API gives JSON format, so PI must converts into XML format for understand, mapping, routing.. etc. So I used REST sender poll adapter which is avialable  on PI 7.31 SP 16 (or) PO 7.4 SP 11.

My sample JSON Format


{“projects”:[{“PKZ”:”AO000″,”projectState”:”yes”,”projectName”:”xyz”},

{“PKZ”:”BE000″,“projectState”:”no”,”projectName”:”abc”}]}

My JSON structure is very big , but I short you for very few fields with values. see in my JSON , “projects” is root tag of JSON and there are two datasets.


According to JSON format, I have created the datatype, message type in ESR( the data type structure is very important, you need to create right way according to your JSON structure)


RestAPIDatatypeon ESR.jgp.jpg


see in the screen shot ‘projects’ should be 0 … unbounded , because we have multiple datasets on JSON.


Importantant Note: I heard from some blogs multiple data sets not possible to convert JSON to XML ,but on PI 7.31 SP 16 (or) PO 7.4 SP 11 is possible to convert multiple data sets, so we do not need any customer adapter modules



See I only added screen shot of Datatype which created on PI ESR. I do not cover any data type structure of JDBC, message type, Message interfaces, mapping… etc. You can create as usual according normal integration scenario.



Integration Directory settings

This is my sample REST Web service URL:  https://tools-dev:9007/ceres/data/basic?lastChangedTime=2015-06-01T01:00:00Z

But i have to generate dynamic value on URL when PI calls the Rest web service  using GET operation. so we need to set up our connection according to that.




Sender Adapter poll:


See in the REST sender adapter , we can able choose REST (or) REST Pooling in the message protocol, selected REST polling according my requirement


RESTPollingAdapter.jpg

Now in the ‘General’ tab. i used only basis authentication. Note: but make sure if your web sevice requires certificate based login then use client certificate authentication check box. in my case I just imported REST web service certificate into PI NWA but I didn’t used the client certificate authentication section . in my case I get  error without certificate import.

Quality of Service: Exactly once  (because i used asynchronous)

RestsenderGeneralTab.jpg

RestGeneralTabadditional.jpg

In the HTTP Request tab, specify your HTTP/HTTPS url for call Rest API webservice and choose REST operation and Polling Interval.

See in the URL I used “{incrementalToken}” for generation of Dynamic value using Incremental Requests

(Setting up Incremental RequestsFor REST APIs that allow incremental requests, the adapter allows to store the timestamp of the latest call or a custom value (specified by an XPath expression or a JSON element). The value will be stored between the calls and can be referenced in the REST URL as a placeholder with name incrementalToken)

HTTP operation : GET

Polling Interval time : accroding to your freequency of Data

RESTHTTPRequest.jpg

In the ‘ Data Format ‘ Tab choose data type format that PI receives from Rest

Check the box that “convert JSON to XML

ADD Wrapper element section : Put your message type which has created in ESR and Namesapce of message type

RestDataFormat.jpg

In the same tab “Data format” there are  few more other options to use. but in my case I used only “incremental Requests” for generate the dynamic value on REST URL when PI calls the REST web service for fetch data(GET)


See in the incremental Requests section, I choose the incremental type is “Timestamp of Last call”

Time stamp format should be ISO 8601

initial value  for one time request( it should require)


RESTIncrementalRequest.jpg

I hope it will help you how to use Rest Sender poll adapter

In this blog I only pointed out how you can fetch the data  using sender REST poll adapter. I do not concentrating on Target side.

Thanks & Best Regards,
Sateesh

To report this post you need to login first.

13 Comments

You must be Logged on to comment or reply to a post.

      1. vikram anne

        Hi Sateesh,

         

        I just want to add additional HTTP header for REST receiver adapter, i had heard that a new tab has been added in latest patch,but we didnot update our PO system,so is their any way by which i can achieve this?

        (0) 
        1. Maheswarareddy Konda

          Hi Vikram,

           

          Unfortunately there is no other option to use HTTP headers.

           

          but that feature is available from 7.41 SP10/7.31 SP15..u can upgrade PI Server.

           

           

          BR,

          Maheswarareddy

          (0) 
      2. Ravi Aalla

        Hi Sateesh,

         

        We have one requirement like ( REST<->PI<->Proxy) . I have created two data types for third party (Input and response) and two data types for sap systems and message types, message interfaces),My input message type Like

        Row……(0…Unbound)

           date….0-1

           PROJECTID..0…1

         

        response like

         

        Row..(0…Unbound)

            Project  (0..1)

            Startdate (0..1)

            enddate  (0..1)

        we completed all the steps in ESR and also configured REST(sender) adapter and XI adapter in ID,

         

        Rest adapter details Like:

        General Tab:

        data format: JSON

         

        In Channel Selection tab:

        Endpoint:: Row/ProjectData/PROJECTID

         

        when we test below URL facing error:

        URL::  https://XXXXXX:50000/RESTAdapter/Row/PROJECTID/

        error is Java.Lang.NullPointer Exception.

         

        Could you please help on this.

         

        Thanks

        Ravi

        (0) 
        1. Maheswarareddy Konda

          Ravi,

           

          Since you are getting Nullpointer exception,,,we will see config later..

           

          can u pls confirm, are you able to see any data in that log and if you able to see , wat type of data like xml or json?

          (0) 
              1. Ravi Aalla

                we are not sending any data through this Url,when we execute the this URL we need project information from SAP system as response.

                (0) 
  1. RAVIJEET DAS

    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 record ?

     

    Thx in advance

    Ravijeet

    (0) 
    1. Sunil Mavachee

      Hi Ravijeet,

      We are working on similar scenario ‘Sender REST with Polling’ – Incremental token of timestamp.

      I believe you are able to trace the log of it “I was able to figure this out, I changed the polling logs to debug level and I was able to view the constructed polling http url”

      Appreciate if you could share the same please.

      Thanks and Regards,

      Sunil

       

       

      (0) 

Leave a Reply