Request Mapper

Basic Request Mapper

Overview

This node, named "Request Mapper," is designed to transform and map input data items by modifying their fields according to user-defined rules. It supports two modes of operation: manual mapping where fields are edited one by one, and JSON-based mapping where fields can be set from a JSON object.

Common scenarios for this node include:

  • Reshaping incoming data to match the expected format of downstream nodes or APIs.
  • Adding, updating, or removing specific fields in each item.
  • Converting field values to different types such as string, number, boolean, array, or object.
  • Filtering output fields by including or excluding certain fields.

Practical examples:

  • Mapping API response data to a simplified structure before further processing.
  • Setting default values or computed fields on each item.
  • Extracting only relevant fields from complex input data for reporting or storage.

Properties

Name Meaning
Mode Selects how to edit item fields:
- Manual Mapping: Edit item fields one by one.
- From JSON: Edit item fields from a JSON object.
Fields to Set Defines the fields to add or modify in the output data. Each field has:
- Name: The target field name (supports dot notation, e.g., data.person[0].name).
- Type: The value type (String, Number, Boolean, Array, Object).
- Value: The value to assign, matching the selected type.
Fields to Include Comma-separated list of field names to include in the output. Only these fields will be kept if specified.
Fields to Exclude Comma-separated list of field names to exclude from the output. These fields will be removed if specified.

Output

The node outputs an array of items where each item's JSON data reflects the applied mappings and filters. The structure of each output item corresponds to the transformed input with fields added, modified, included, or excluded as per the node configuration.

If binary data were supported, it would represent attached files or media, but this node focuses solely on JSON data transformation.

Dependencies

  • No external services or API keys are required.
  • The node relies on internal helper functions (from a bundled executor module) to perform the actual data transformation logic.
  • No special environment variables or n8n credentials are needed.

Troubleshooting

  • Incorrect field paths: Using invalid dot notation or array indices in field names may cause fields not to be set correctly. Verify field names carefully.
  • Type mismatches: Ensure that the value provided matches the selected type (e.g., numbers for Number type). Invalid types might lead to unexpected results.
  • Empty output: If both "Fields to Include" and "Fields to Exclude" are misconfigured (e.g., excluding all fields), the output may be empty.
  • JSON parsing errors: When using the "From JSON" mode, ensure the JSON syntax is valid to avoid errors during execution.

Links and References

Discussion