0

I have a GET request inbound at my localhost. I have extracted all the URI parameters from the request and stored them in session variables. Now the problem I'm facing is when I try to set map as payload using session values.

While searching for correct method to do so I stumbled upon this.

The method described here is correct and it works in following case when I hard code the key-value pair.

<set-payload value="#[['Test' : 'hjhj' ]]"  encoding="UTF-8"/>

Following message is printed:

Payload               : {Test=hjhj}
Payload Type          : java.util.HashMap

But when I use the same method and write the following code using session variable:

 <set-session-variable variableName="transactionAmount" value="#[message.inboundProperties.'http.query.params'.amount]" doc:name="Session Variable"/>

<set-payload value="#[['Test' : #[sessionVars.transactionAmount] ]]"  encoding="UTF-8"/>

Message which gets printed:

Payload               : {Test=[1]}
Payload Type          : java.lang.String

Please tell me how I can overcome this problem. I'm stuck in this for long.

NOTE: I'm using Mule 3.9

Thanks in Advance!!

Anand Singh
  • 87
  • 10
  • Why are you using session vars instead of flow vars? By default you should use flow vars. – aled Nov 29 '19 at 13:50

1 Answers1

2

No need for the nested expression evaluators #[]

Try this:

<set-payload value="#[['Test' : sessionVars.transactionAmount]]" />
Ryan Carter
  • 11,441
  • 2
  • 20
  • 27