You can access and reference export and lookup HTTP response headers with handlebar expressions when building transformations or transformation scripts. When using lookups to retrieve images and header data, you must use results mapping to map the header data before you can pass it on to the rest of your flow. While there are many practical applications, the most common use cases include:
-
Retrieving and passing response header data to the next step in your flow
-
Retrieving response headers when managing blob data
Important
To use a response header in other parts of your flow, complete the following two-step configuration:
-
Transformation: Use a handlebar expression (for example, {{headers.content-type}}) and set an Output field name. This places the header value onto each record under that field name.
-
Results mapping: Map the transformed field from data[*].<OutputFieldName> (Extract) to the destination field name you want downstream steps to see (Generate). The Extract field name must match the Output field name you set in the transformation; otherwise the header value will not appear in the payload.
Use the following steps to reference HTTP response headers with a handlebars expression:
-
Click Settings (
) for the transformation row.
-
Select Handlebars expression from the Field transformation type drop-down list.
-
Click Handlebars (
) to open the Build handlebars expression AFE.
In this use case, you're retrieving a specific receipt, identified by its receiverID (also known as transactionID). When retrieving the receipt, 3PL Central provides an eTag value in the response header that you can use in further requests.
For example, after retrieving the eTag value, you can use it in a PUT request to update an unconfirmed receiver. Where previously you'd need to use a workaround to retrieve the eTag, now you can retrieve and transform it directly through integrator.io using handlebars.
Step 1: Configure the transformation
-
Open your transformation settings (⚙️) and add a rule with the following:
-
Set Field transformation type to Handlebars expression.
-
In the Handlebars expression, enter {{headers.eTag}}.
-
In the Output field, enter eTag.
The Output field name (eTag in this example) is the name under which the header value will be written onto each record in the data array. You'll reference this exact name in results mapping in Step 2.
Step 2: Configure results mapping
-
Open HTTP results mapping for the lookup.
-
Add a new mapping.
-
In the Extract (source) field, enter
data[*].eTag. -
In the Generate (destination) field, enter
eTagor the field name expected by the downstream PUT request.The segment after
data[*].must match the Output field name from Step 1 exactly. Thedata[*]prefix is required because transformed fields are written into thedataarray.
In this use case, you're using SAP Concur to retrieve expense report images.
The Content-Type response header identifies the file type for each record. To make this information available to downstream steps, add it to the record.
Step 1: Configure the transformation
-
Open your transformation settings (⚙️).
-
Add a new transformation rule.
-
Set Field transformation type to Handlebars expression.
-
In the Handlebars expression, enter
{{headers.content-type}}. -
In the Output field, enter
contentType.
The Output field name (contentType in this example) is the name under which the header value is written to each record in the data array. You'll reference this exact name in results mapping in Step 2.
Step 2: Configure results mapping
-
Open HTTP results mapping for the lookup.
-
Add a new mapping.
-
In the Extract (source), enter
data[*].contentType. -
In Generate (destination), enter
FileTypeor any field name you want downstream steps to use.
The contentType segment must match the Output field name from Step 1 exactly. The data[*] prefix is required because transformed fields are written into the data array.
Step 3: Verify
You can force an error in the next step to inspect the raw payload and confirm that the FileType field is now present alongside the rest of the record, and that its value matches the original Content-Type response header.
Common mistakes
-
Omitting the
data[*]prefix in the Extract field. Results mapping looks for transformed fields in thedataarray and will not find them at the root of the response. -
Using the original header name (for example,
Content-Type) as the Extract field. Use the Output field name defined in the transformation (for example,contentType) instead. Results mapping reads from the transformed record, not from the raw response headers. -
Changing the Output field name without updating the Extract field. The field name used after
data[*].in the Extract field must exactly match the Output field name defined in the transformation.