cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic http header in receiver rest adapter

kevin_chirinos
Explorer
0 Kudos
Hi gurus,I have a problem when I try to put the dynamic http header. If I put a static value, the interface works fine, but if I change that value to a variable, the interface throws an error. If the dynamic configuration is checked, the value of the variable is correct. Please, any suggestions?

The code in the UDF:
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); 
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/REST","HeaderAuthorization");
conf.put(key1, token); 
return token;

Accepted Solutions (1)

Accepted Solutions (1)

former_member607993
Contributor
0 Kudos

Hello Kevin,

In the REST receiver communication channel under 'REST URL' Tab you can specify the pattern variable replacement correctly. Since the Authorization is generated dynamically the pattern variable replacement looks like. I could

Value Source: Adapter-Specific Attribute

Pattern element Name: Authorization

Adapter Specific Attribute: Custom Attribute

Attribute Name: Authorization

Also ensure in the UDF code the attribute name is changed from Header Authorization to Authorization only.

Now Under 'HTTP Headers' Tab you can specify the HTTP headers as below:

Header Name: Authorization

Value Pattern: Bearer {Authorization}


Thanks and Regards - Rajesh PS

kevin_chirinos
Explorer
Hi Rajesh, with what you mention the interface finally works, thanks
chetan_risbud
Participant
0 Kudos

rajeshps - I am facing similar problem

If I change everything to Authorization its not working

Working in case of any other keyword eg token,Auth etc.

But header attribute name should be "Authorization" as per API specification.

Regards,

Chetan Risbud

former_member499364
Participant
0 Kudos

Can you try it with authorization instead... I mean if you use a small "a"

chetan_risbud
Participant
0 Kudos

taran85 - Yes it will work if everything is set to authorization but when I set parameter in headers tab as Authorization its not working.

Please refer below screenshot for the same.

chetan_risbud
Participant
0 Kudos

engswee.yeoh michal.krawczyk2 evgeniy.kolmakov - Hello Experts,

Can you please help , I have tried all possibilities but nothing is working

Answers (5)

Answers (5)

varun_kasireddy
Explorer

Hi Rajesh,

I tried same thing what you suggested above, but its not working for me.

Can you please advise what am missing here ?

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/REST","Authorization");
conf.put(key1, var1);
return var1;
jaxiwang_jaxiwang
Discoverer

Hi Varun K:

I have the same issue as yours . Do you have resolved this issue ? Appreciate your reply !

chetan_risbud
Participant
0 Kudos

Im facing exact same issue.

Can you confirm the solution.

iker_espinosa
Participant
0 Kudos

That's OK.

I also get "Set HTTP Header Authorization to ***" but if you use xpi_inspector with that REST channel you would see that http authorization is correct.

vicky20691
Active Contributor

Hi,

Please use HTTP Headers as below

regards,

Vikas

manoj_khavatkopp
Active Contributor

Under "Pattern variable replacement" can you change it from Adapater specific to custom attribute.

If you still facing issue please add the error screenshot.

former_member499364
Participant
0 Kudos

Hi Varun/Rajesh,

We have a similar requirement, where we need to pass the generated token value to the nwBPM flow as header. we have followed exactly the same process and UDF as mentioned in the blog and we are getting the error : "Server returned code: 415" and

" HTTP error occurred: Unsupported Media Type 8/11/2020 03:28:37.087 PMErrorMP: exception caught with cause com.sap.aii.adapter.rest.ejb.common.exception.HttpCallException: HTTP POST call to http://po url/bpm/pwccom/syscentricdevgooglesdmsc/TriggerUploadProxy?wsdl not successful. Unsupported Media Type"

Can you please share how did you fix this error.

Adding screenshots:-

1) UDFudf.jpg

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/REST","Authorization"); conf.put(key1, var1); return var1;

2) REST URL rest-url.jpg

3) HTTP Header http-header.jpg

4) Error : error.jpg

former_member499364
Participant

This solution worked once I changed channel configurations as shown.workingconfig.jpg

ravicarpenter
Active Participant
0 Kudos

Please mention the error details