postman - 您使用这些参数调用了函数“值选择器”
问题描述
我正在使用 Mulesoft 实施 LoanBroker,但在发送请求时出现错误消息。我从 Postman 和 Mulesoft Anypoint Studio 收到以下错误消息:
ERROR 2021-06-27 15:20:51,133 [[MuleRuntime].uber.04: [loanbroker].LoanBrokerFlow_Gr7.CPU_LITE @254be3ee] [processor: LoanBrokerFlow_Gr7/processors/0; event: 7e49f560-d74a-11eb-b598-b66921dc5aa5] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:
********************************************************************************
Message: "You called the function 'Value Selector' with these arguments:
1: Binary ("" as Binary {base: "64"})
2: Name ("amount")
But it expects one of these combinations:
(Array, Name)
(Array, String)
(Date, Name)
(DateTime, Name)
(LocalDateTime, Name)
(LocalTime, Name)
(Object, Name)
(Object, String)
(Period, Name)
(Time, Name)
1| payload.amount
^^^^^^^^^^^^^^
Trace:
at main (line: 1, column: 1)" evaluating expression: "payload.amount".
Element : LoanBrokerFlow_Gr7/processors/0 @ loanbroker:bi_gruppe7.xml:34 (Copy_of_setAmount)
Element DSL : <set-variable value="#[payload.amount]" doc:name="Copy_of_setAmount" doc:id="cbcca557-1a69-4cf2-80b1-64333175589d" variableName="amount"></set-variable>
Error type : MULE:EXPRESSION
FlowStack : at LoanBrokerFlow_Gr7(LoanBrokerFlow_Gr7/processors/0 @ loanbroker:bi_gruppe7.xml:34 (Copy_of_setAmount))
(set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
谁能帮我?
谢谢
解决方案
这通常发生在尝试访问像 json 这样的有效负载的内部值但传入的有效负载实际上不是 json 类型时。
可以检查有效负载mediaType
,然后尝试访问金额以避免值选择器异常。
%dw 2.0
output application/java
---
if( !isEmpty(payload) and payload.^mediaType contains "json" )
payload.amount
else
read(payload, "application/json").amount //best effort
建议创建一个单独的 dataweave 文件dwl/set-amount.dwl
并引用它。
推荐阅读
- html - Angular - Primeng 的 confirmDialog 显示在 ng-bootstrap 的模态后面
- tfs - TFS 2018 更新 2 升级:报告服务
- ios - 您可以在企业应用程序上进行实时部署吗?
- r - 使用 sf 将点捕捉到线段上的最近点
- haskell - 使用同名函数继承类型类
- r - 有没有办法在闪亮链接中打开用户的小插图?
- javascript - 从 iOS 9.3.5 到最新 iOS 的 HTML 差异
- vba - 提高宏执行时间的方法
- javascript - 使用 $sum 和 $cond 获取 $sum 的值,而不是 mongo 中的实例总和
- vue.js - Vuetify 离线文档