22

SAP PO 7.5 REST Lookup - Issues in passing dynamic values in HTTP Header and cus...

 1 year ago
source link: https://answers.sap.com/questions/13445307/sap-po-75-rest-lookup-issues-in-passing-dynamic-va.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Jul 26, 2021 at 08:03 PM

SAP PO 7.5 REST Lookup - Issues in passing dynamic values in HTTP Header and custom Error handling

475 Views

Hi All,

I am working on a JMS to PROXY flow in which we have got a requirement to perform REST Lookup in the message mapping by passing dynamic values(some from incoming payload and some determined by small logic) in HTTP Header of the REST Lookup call. Also, I need to print the response(custom error log) from the REST Lookup in case the HTTP response code is not 200 (for any type of error code) and fail the message. I have some issues mentioned below, kindly share your inputs.

I have tried to put the incoming variables and some other logic determined values in Dynamic Config in mapping UDF and fetch them in REST Receiver channel and map them in HTTP Header section, but what I see is,

  1. The values are set properly and visible in Dynamic config in main message (incoming payload), but in the Lookup channel it shows as BLANK as shown below. So no values are passed to REST API and it returns error each time. This setup works fine in POSTMAN tool.
1959764-main-message-dynamic-conf-values.png

Lookup channel log is below,

1959765-lookup-channel-log.png

I tried to validate if the Dynamic config is having issues or not by creating a REST to REST flow and see that the values are set properly in main message.

Below is the code from UDF,

AbstractTrace trace = container.getTrace();
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
//put header params in dynamic configuration.
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/REST","XHeaderName1");
DynamicConfigurationKey key2 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/REST","XHeaderName2");
DynamicConfigurationKey key3 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/REST","XHeaderName3");
conf.put(key1, DocType);
conf.put(key2, msgId);
conf.put(key3, BusinessID);
return "";

And below is the config in REST Lookup channel,

1959766-channel-1.png
1959767-channel-2.png

2. I also need to catch the response from the REST Lookup to add it in the Audit log of main message and fail it in case of error, but the above error log is not available in main message. Below is the setup in REST Lookup channel in last tab. I only get a single string value for {http_result} in response payload. Is there any specific thing like creating the below structure as a separate external def or DT and use it?

1959768-rest-receiver-channel-error-handling.jpg

3. Once I sort 1st issue, get error code from 2nd point, how to pass the above error log in Audit log, kindly let me know. I tried to follow this link and related notes and params in Module tab, but still no luck.

Thanks and regards,

Rajesh S.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK