Access Response Header Value in HTTP Module

How can I access a specific response header value (e.g. “Location”) when performing a POST request using the HTTP module?

Hi @Jorg_Ackermann ,
Great question!

When using the HTTP module you can access the response headers by using the Headers[] from the output of the call. This would retrieve you an array with items having all headers within the request.

Now if you want to extract some kind of specific header value which has a specific key, you can use the map() and get() function.

First use map() to create a new array from a mapping you make:

{{map(1.headers; "value"; "name"; "headerkey")}}

This mapping basically says: “retrieve all values, where the name is equal to headerkey” (I placed a header in there with a key called “headerkey”.

Using the map() function you will get a new array. If you want to get a text value instead, use the get() function to retrieve the first and only item:

{{get(map(1.headers; "value"; "name"; "headerkey"); 1)}}


Success! Hope this helps you.
Let me know if you have any more questions.

3 Likes

Hello,
is it also possible to get header from any other module and app which is not HTTP module? Is there any function for this?
I don’t have any Headers array on input or ouput of that module when I run it.

Thank you!

You saved my day, thank you! It’s surprising that there is no easier way of getting out a single value from an array :confused:

No @devhype , unless the app is built like that, it won’t be possible.
You can however use the Make Dev tool or Google Console and see the full request including headers.

No problem, it takes a little bit of practice yes. You don’t need to use the “Set Variables” module however, but that was just an example.

1 Like