cancel
Showing results for 
Search instead for 
Did you mean: 

How to add parameters to the Header of REST response

yasha_dubey
Participant
0 Kudos

Hello All,

I below scenario synchronous call from Portal as shown below

Portal ----> SAP PI --->  ECC . I am using Rest Adapter as I have JSON to XML conversion and vice versa.

The problem here is that when the portal team run the request via internet explorer there is no issue, but it fails in chrome as chrome expects these two parameters additionally.

"Access-Control-Allow-Origin" = "*"

"Access-Control-Allow-Headers" = "Authorization"

Is there a way to handle this in PI, as in to alter the header response while sending back to Portal ?

I am little new to Rest, can't figure out.

Thanks in advance for your help!!

Pragya

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

Hi Pragya

Are you using SAP's REST adapter? If yes, then I don't think this feature is available yet.

What you are referring to as parameters are actually HTTP headers.

The latest SP for PI/PO (as mentioned below) only supports setting custom HTTP headers on REST receiver channel.

Setting custom HTTP header for responses via the sender channel is available on Advantco's REST adapter, but I'm not sure which one you are using.

Rgds

Eng Swee

yasha_dubey
Participant
0 Kudos

Dear Eng Swee,

Thanks for the reply. I am not using Advancto. Since Authorization and Origin are actual Headers is there a way I can see what is actually getting populated in my response ?

Also, can I specify this header explicitly via some adapter modules like we can do in Axis ?

Thanks,

Pragya

engswee
Active Contributor
0 Kudos

Hi Pragya

I don't think you would be able to see the HTTP headers in the Message Monitor.

Maybe you can try using XPI inspector to see if you can view HTTP headers of the response.

Another alternative would be to use a REST client to test out the REST adapter. You can try the free Chrome extension below - it is similar like SOAPUI. The REST client would show the response HTTP headers.

Advanced REST client - Chrome Web Store

I've never used the Axis adapters, so I won't be able to comment on that.

Rgds

Eng Swee

yasha_dubey
Participant
0 Kudos

Hi Eng,

Thank you so much, I tried testing via Advanced Rest client, but this header is not populated.

I have one last question, that If I write an adapter module to over-write  the HTTP Response Header will that work  ?

I want to be sure before starting with it as we are running low on time.

Thanks,

Pragya

engswee
Active Contributor
0 Kudos

Hi Pragya

Unfortunately, I haven't done any adapter module development that deals with the HTTP headers so I can't give you a definitive answer. I can only say that I've never come across any API in the PI Java library that allows access to the HTTP headers. You can try to check out the JavaDocs to see if there are any.

PI JavaDocs

Rgds

Eng Swee

yasha_dubey
Participant
0 Kudos

Hi Eng,

Thanks for your help so far !!!

I would raise another thread about the module parameter. We have few standard modules for Axis to change the header.  So lets see if I get some response there.

Thanks again.

engswee
Active Contributor
0 Kudos

You are welcome. Do close this thread if there are no more queries for this.

Answers (0)