Skip to end of banner
Go to start of banner

Response Mapper

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Current »

Overview

Use this policy to transform the API response body. The Response Mapper policy contains a mapping table that evaluates an expression and writes the result to an optional field, which then deletes the path specified in the expression. If an expression fails to evaluate, the API is not executed. The Response Mapper policy also contains a Pass Through option for unaffected mappings. The mapping table works similarly to that of the Mapper Snap.

You can use this policy in the following use cases.

  • Data normalization: This can be used to standardize the format of the data returned by the API, making it easier for clients to consume. For example, you could use a response transformation policy to convert all dates to a standard format, such as ISO 8601.

  • Data security: This can be used to redact sensitive data from the response data, such as credit card numbers or social security numbers. For example, you could use a response transformation policy to replace all credit card numbers with asterisks or even hashing using encodings such as MD5 SHA 256/512.

Null-safe access is enabled by default. This means that the policy catches any exceptions encountered while evaluating expressions and turns the result into a null instead of an error.

Prerequisites

  • You can only apply this policy to your Proxy and Proxy endpoints.

  • The version running on your Snaplex must be the June 2023 release or later.

  • Proxy endpoint output must be in a format that can be converted and parsed as some form of JSON.

Supported Content Encodings

Response Header Content-Encoding supported HTTP content encodings for decoding:

  • compress

  • br

  • gzip

  • deflate

All comressions types are supported for re-encoding except for br encoding.

Usage Guidelines

Always select Pass through if you plan to leave any Target paths field blank.

Expression Enabled Fields in API Policies

All expression enabled fields take expressions from the SnapLogic Expression Language and the API Policy Manager functions.

Limitations

  • If a Proxy endpoint uses a Triggered Task with an open document output view for the response, the response will be a list, which requires that you index it by treating '$' as a list, such as '$[0]' to access the first response document, or the only document (if only one is present).

  • If your incoming data is a list, Pass through is not supported.

Known Issues

APIM functions display in the expressions dropdown menu but do not actually work.

Settings

Parameter Name

Description

Default Value

Example

Label

Required. The name for the API policy.

Request Size Limit

SizeLimit_DevOrg

When this policy should be applied

An expression-enabled field that determines the condition to be fulfilled for the API policy to execute.

True

request.method == "POST"

Pass through

This setting determines if data should be passed through or not.

If you select this checkbox, then all the original input data is passed into the output document together with the data transformation results.

If you deselect this checkbox, then only the data transformation results that are defined in the mapping section appear in the output document and the input data is discarded.

Selected

N/A

Mapping table

The mapping table consists of an Expression and Target field where you enter the mapping.

Expression

The function to use to transform the data. For example, combine, concatenate or flatten. Expressions that are evaluated replace the source targets at the end of the Pipeline runtime.

N/A

$customer

Target

The target JSON path where the value from the evaluated expression is written. For example, after evaluation of the $person.firstname expression the Snap inserts the firstname for the person object. If left blank, the source path is deleted.

N/A

Customer

Status

Indicates whether the API policy is enabled or disabled. 

Enabled

Disabled

  • No labels