Skip to Content
0

REST to Web service Interface - Pick date from sender HTTP url and pass it in mapping

Oct 24, 2017 at 11:47 AM

162

avatar image

Hi Experts,

I am using REST polling sender adapter to retrieve HTTP GET request. In this interface I need to pick the date from sender URL and pass it in Date field in mapping to the target Web service.

sample Sender URL:

http://<server_name>/api234/rowdata/bydate/2017-06-11

Please provide me your suggestions.

Thanks in advance.

Srikanth E

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

2 Answers

Raghuraman S Oct 24, 2017 at 03:19 PM
0

Hello Srikanth,

Using the UDF mentioned in the below link you can get the values from the rest URL and map it to that target structure of WS.

Instead of REST IDS you can define your custom attributes as well.

https://blogs.sap.com/2014/12/18/pi-rest-adapter-using-dynamic-attributes/

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hello Raghu,

The image UDFs in the link given are disabled/unable to open, can you please ping here if you can open them.

Thanks,

Srikanth E

0

Hello Srikanth,

Below is the UDF code

@LibraryMethod(title=“getASMA”, description=“get adapter specific message attribute”, category=“UDFPool”, type=ExecutionType.SINGLE_VALUE

public String getASMA (

@Argument(title=“”) String namespace,

@Argument(title=“”) String attribute,

Container container) throws StreamTransformationException{

Map<String, Object> all = container.getInputHeader().getAll();

DynamicConfiguration dynConf = (DynamicConfiguration)all.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create( namespace, attribute);

String value = dynConf.get(key);

return value;

Inputs are namespace which is standard -

http://sap.com/xi/XI/System/REST.

For attribute select as per the one mentioned in channel.
0

Hello Raghu,

Thanks for the UDF.

I did not understand what to be given as input for attribute, below is my channel configuration.

w6ctp.png (1.6 kB)
0
Raghuraman S Oct 25, 2017 at 11:06 AM
0

Hello Srikanth,

Its like which value you define in the URL pattern Element.

Check the below image.

Define the same in the mapping.


Show 6 Share
10 |10000 characters needed characters left characters exceeded

Hi Raghu,

We are using REST polling for sender and the data should be picked on Incremental request based on timestamp of last call.

The UDF in mapping should pick the timestamp/date from the URLs and pass it to the target.

http://host:server/rowdata/bydate/{incrementalToken}

As REST Polling adapter doesn't have Adapter Specific/URL patter parameters, instead I tried to pass {incrementalToken} as input for attribute but it didn't work.

Can you please guide me further.

Thanks,

Srikanth E


0

Please post the screenshots of channel configuration.

Date you wish to get from the URL right?

0

Hello Raghu,

please find the channel configuration.

Yes, Date should be picked from the URL.

ueitj.png (138.3 kB)
0

Hello Sreekanth,

I don't think its possible with Standard way as I tried the same and URL or the increment requests are not recorded anywhere in SAP PO.I will check more if I can find something.

But since this is only date field why don't you map the current date in the mapping which will change everyday.

1

Hello Raghu,

Thanks for your response.

but we have to pick old data as well and the old data and date is not regular(eg: 2017-08-08, 2017-08-10... 2017-08-11) :|

In this case current date cannot work.

Thanks,

Srikanth E

0

OK Srikanth.

This is actually little weird and which SAP PO version and SP your using.

Can you try keeping some HTTP headers and see if those values are getting reflected.

In my version HTTP headers are not working seems to be bug.

0