You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

API Connect 2018中Redact Policy使用求助:移除指定字段

Fixing Redact Policy to Remove "Status Code" Field in API Connect 2018

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

  1. Open your API in the API Connect 2018 editor.
  2. Navigate to the Assembly tab.
  3. 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., response if 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:
      $.Details['Status Code']
      
      The single quotes around Status Code are 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).

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 Details or Status Code.
  • The message type (request/response) matches where your payload exists.

内容的提问来源于stack exchange,提问作者Aritra Dasgupta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:48:08