1

I am in the process of implementing a LoanBroker with Mulesoft but have an error message when sending a request. I get the following error message back from Postman and 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)
********************************************************************************

Can anyone help me?

Thanks

Anton Krug
  • 1,555
  • 2
  • 19
  • 32

3 Answers3

1

This generally happens when one tries to access inner value of a payload like json but incoming payload is NOT actually a json type.

One could check the payload mediaType and then try to access the amount in order to avoid Value Selector exception.

%dw 2.0
output application/java
---
if( !isEmpty(payload) and payload.^mediaType contains "json" )
   payload.amount
else
   read(payload, "application/json").amount //best effort

Would recommend creating a separate dataweave file like dwl/set-amount.dwl and referencing it.

Dharman
  • 30,962
  • 25
  • 85
  • 135
0

You are probably sending some body in the HTTP request from Postman but Mule doesn't know how to read it. Maybe you did not the Content-Type header in the request to let DataWeave know it is a JSON (application/json) or XML (application/XML). Ensure you are sending the right content type.

aled
  • 21,330
  • 3
  • 27
  • 34
0

I ran into the same situation. I know exactly the base64 is a json. So, I tried to set the MIME Type by

<set-payload value="#[payload]" doc:name="Set Payload" mimeType="application/json"/>

It works for me.

Minh Trần
  • 356
  • 4
  • 13