Response Mapper rule

Transforms the response body. The Response Mapper rule 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 rule also contains a Pass Through option for unaffected mappings. The mapping table works similarly to that of the Mapper Snap.

You can use this rule 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 rule 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 rule to replace all credit card numbers with asterisks or even hashing using encodings such as MD5SHA 256/512.
Note: Null-safe access is enabled by default. This means that the rule catches any exceptions encountered while evaluating expressions and turns the result into a null instead of an error.

Requirements

  • The 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
Note: All compression 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.

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

Starting in the October 2023 release, the Response Mapper and Response Transformer rules support the request and response functions in the APIM Expression Language. These functions enable you to modify the headers for your Proxy endpoints quickly. When you click experssions tab to enable the expression dropdown, you can access these 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.

Field Description
When this rule should be applied An expression that defines one or more conditions that must be true for the rule to execute.

Example: The expression request.method == "POST" causes the rule to execute only on POST requests.

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.

Default value: Selected

Mapping table The mapping table consists of an Expression and Target field where you enter the mapping. The name for the API policy.
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.

Example: $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.

Example: Customer

Description Use this rule to transform the API response body.

Default value: Response body fields are being remapped as specified