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

Power Automate自定义连接器调用Coupa API时custom-fields无法返回

关于Power Automate自定义连接器调用Coupa API的字段过滤问题

问题描述

在Power Automate中通过Swagger/OpenAPI构建自定义连接器调用Coupa API时,不使用fields查询参数能正常返回包含custom-fields嵌套对象(如tipo-de-requisicao、organizacao-de-compras)的完整JSON响应;但使用fields参数过滤结果时,custom-fields块会被完全省略。

当前GET操作的Swagger定义

get:
  summary: Get Requisition by ID
  operationId: GetRequisitionById
  parameters:
    - name: id
      in: path
      type: string
      required: true
    - name: fields
      in: query
      type: string
      required: false
      default: >-
        ["id","status","created-at","submitted-at","total","ship-to-attention",["custom-fields",["tipo-de-requisicao",["id","name"]]]]
    - name: Accept
      in: header
      type: string
      required: false
      default: application/json

预期响应(简化版)

{
  "id": 130608,
  "status": "received",
  "custom-fields": {
    "tipo-de-requisicao": {
      "id": 173,
      "name": "YREG Regularização / Regularization"
    }
  }
}

实际响应

{
  "id": 130608,
  "status": "received",
  "ship-to-attention": "Loren Epson",
  "total": "62710.40",
  "moved-lines": false
}

推测原因

Power Automate会自动对fields参数值进行URL编码,将[转换为%5B、]转换为%5D,导致Coupa无法正确识别嵌套字段的数组语法。

已尝试方案

  • 修正括号语法:["custom-fields",["tipo-de-requisicao",["id","name"]]]
  • 拆分为两个独立查询参数(fields和fields[custom-fields])
  • 不使用fields过滤器调用(可正常返回完整JSON)

核心问题

  1. 能否不通过C#代码,在Power Automate自定义连接器中向Coupa API传递嵌套fields过滤器?
  2. Coupa是否支持避免括号符号的嵌套custom-fields过滤替代语法?

解决方案

针对问题1

可以通过调整Swagger参数配置或使用Coupa支持的扁平化字段语法实现,无需编写C#代码:

  • 调整Swagger参数序列化:将fields参数的类型改为array,并设置style: form、explode: false,让Power Automate以逗号分隔的格式传递字段,而非数组括号格式。
  • 使用扁平化语法:直接采用Coupa支持的点分隔格式(见问题2的答案),彻底规避括号编码问题。

针对问题2

Coupa支持点分隔的扁平化字段语法,无需使用数组括号即可指定嵌套字段。例如要获取目标嵌套字段,fields参数值可写为:

id,status,created-at,submitted-at,total,ship-to-attention,custom-fields.tipo-de-requisicao.id,custom-fields.tipo-de-requisicao.name

将此值设置为Swagger中fields参数的默认值,Power Automate会直接传递该字符串,不会触发括号编码,Coupa也能正确解析并返回custom-fields块。


内容的提问来源于stack exchange,提问作者tales duran

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 10:40:36