Enrich HTTP Headers in Logic Apps

Recently, I read a question about a Logic App that received an HTTP request.  The purpose of the Logic App was to add some extra HTTP headers to the request, while retaining the orignal ones, before forwarding the message to another HTTP endpoint. This short blog demonstrates how you can enrich HTTP headers, without losing the orignal HTTP headers.

The solution

Our Logic App consists of three actions:

Enrich HTTP Headers - 1

The first shape is an Request trigger that receives the original request.  Default configuration.

The second one is an Initialize Variable that constructs the new HTTP Headers object.

Enrich HTTP Headers - 2

The third action forwards the original request to a RequestBin endpoint.  Notice that the Headers parameter accepts both key-value pairs or JSON objects.  I use the following expression to merge the new with the orignal HTTP headers:

@union(triggerOutputs().Headers, variables('NewHeaders'))

Enrich HTTP Headers - 3

Edit: I received the question if this can be done without an intermediate Initialize Variable action.  Yes, it’s possible.  A little cheaper, but a little less readible:

 union(triggerOutputs().Headers, json('{  "x-new-header-3": "header-3",  "x-new-header-4": "header-4"}'))


Let’s send an HTTP request to the Logic App, with 2 original HTTP headers.

Enrich HTTP Headers - 4

If we now inspect the received request in RequestBin, we see that the two new HTTP headers are appended to the original ones.  Additionally, some default Logic Apps HTTP headers are added to the request too.

Enrich HTTP Headers - 5.PNG


By using the @union workflow function, we are able to easily append additional values to the incoming HTTP headers.

Hope this was a useful one!

One thought on “Enrich HTTP Headers in Logic Apps

  1. Pingback: Microsoft Integration Weekly Update: Sep 4 | Hooking Stuffs Together

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s