How to read http headers

I am trying to read the value of a specific header from an HTTP request and assign it to a page variable. Is this the correct way of doing that?

outputs["HTTP request"].resHeaders['header-name']

Hi,

Yes this seems fine, did you try it? Another option to try would be outputs["HTTP request"].resHeaders.header_name

What I posted does not work. I’ll try what you mentioned.

Hello,
[“HTTP request”].resHeaders.header_name does not work either.

Hi,

I did some testing, and it seems like [“HTTP request”].resHeaders comes in a map object. So try using outputs["HTTP request"].resHeaders.map['header-name']

Hello,

I tried using outputs[“HTTP request”].resHeaders.map[‘header-name’] to assign the specific http request header to a page variable (text) and display it on the page but it is not showing anything.

Hmm strange! I have this exact setup and it works. Are you sure the HTTP Request is working and that the header you are trying to get really is in the response header?

Yes, I know for a fact that the http request is working and the header is present in the response (I can see both in the developer tools in the preview)

OK I see what’s going on. It works in the preview app but doesn’t work in the web app.