API Connect 2018中Redact Policy使用求助:移除指定字段
Hey there! I’ve helped folks troubleshoot this exact issue before—let’s get your Redact Policy working properly to strip out that "Status Code" field from your nested JSON response.
The key mistake most people make here is not handling the space in the field name correctly in the JSONPath, or missing the nested Details parent object. Here’s a step-by-step breakdown:
Step 1: Add the Redact Policy to your API Assembly
- Open your API in the API Connect 2018 editor.
- Navigate to the Assembly tab.
- Drag the Redact policy from the palette into your assembly flow (place it where you want to modify the message—likely after the backend call if this is a response transformation).
Step 2: Configure the Policy Correctly
Click on the Redact policy to open its configuration panel, then set these values:
- Message: Select the message you want to modify (e.g.,
responseif this is cleaning up the backend response). - Redaction Targets: Click Add to create a new target:
- Type: Choose
JSON(since your payload is JSON). - Path: Enter the correct JSONPath for your nested field:
The single quotes around$.Details['Status Code']Status Codeare critical here—they let JSONPath handle the space in the field name. Omitting them will cause the policy to fail to find the field. - Action: Select
Remove(this tells the policy to delete the field entirely).
- Type: Choose
Step 3: Verify the Raw Policy Configuration
If you prefer to view the assembly’s YAML directly, your Redact policy should look like this:
redact: version: 1.0.0 title: Remove Status Code Field description: Redact the Status Code field from the Details object targets: - type: json path: "$.Details['Status Code']" action: remove
Step 4: Test the API
Deploy your API and send a test request. Your response should now look like this (with "Status Code" removed):
{ "Details": { "UT_LL": 22235, "UT_ZZ": 512, "UT_DATE": "2019-10-02-11.36.16.353965", "UT_TOTAL_REC": 132 } }
If it’s still not working, double-check that:
- The policy is placed in the correct part of the assembly flow (it needs to run after the payload is generated).
- Your JSONPath is exactly as written—no typos in
DetailsorStatus Code. - The message type (request/response) matches where your payload exists.
内容的提问来源于stack exchange,提问作者Aritra Dasgupta

