Please find enclosed 3 screenshots in one of above usecase in debug mode , I am trying to obtain the result in json format but I am getting the result as mentioned in lower screenshot in postman .
Please help .
Thanks
Can you add ObjectToJson converter as below
<json:object-to-json-transformer doc:name="Object to JSON"/>
Add this component at the end of your flow. This will solve the issue.
Related
Need small help to retrieve values which are in error.errorType as per attached screenshot.
I need values of asString, identifier and namespace from error.errorType.
And need dataweave expression code to write in transform message in Mulesoft.
enter image description here
You could refer to these with the .(dot) notation and that should work for you?
Script
%dw 2.0
output application/json
---
{
errorAsString: error.errorType.asString,
errorIdentifier: error.errorType.identifier,
errorNamespace: error.errorType.namespace
}
Grabbed a screenshot for you from a sample app that i created to demonstrate this.
I have scatter gather component which calls multiple services and aggregates the result as list of maps. I would like to know is there any way to merge the original payload ( payload which is an input to Scatter Gather) with this result?
Say if you have a map(Key value pair) given as input to scatter-gather flow.And Scatter-gather in turn gives out list of Map.Then you can follow below steps
Store the "input" to scatter-gather into a flowVar/SessionVar depending on your need.
Once you are out of scatter-gather flow,add Set Payload transformer.
In "Set Payload" transformer add [payload.addAll(flowVars['flowVar_Name_which_you_saved_earlier']) as value.
Alternate way is to use "set payload" inside scatter-gather and set the value of the input payload from flowVar. In this case Dataweave "flatten payload" is enough at the end- which is going to be used anyway.
can someone pls advise how to access values from a context:property-placeholder in MEL?
I've found an article that describes how to access the values from Java here.
Need similar for MEL.
Thanks,
It is simple mostly same as in Spring container of java. You access it using ${key} where key is present in your properties file.
OK, I had to find the answer by myself.
The syntax of accessing a property value in MEL depends on a type of the value.
For String values it should be like this:
MyStringVar='${MyProperty}';
while for numeric values the quotas not required.
you can try with ${propertyName}, where ever you want to access properties.
You should be able to access the property value as shown below:
<set-variable variableName="someName" value="${xyz.someProperty}" />
In MUnit Mock Message Processor how do we specify a non specific payload such as Mule Message Collection (comma separated XML data) in the return with message payload field.
In general if we just hard code the value, it would be taken as a string which makes it difficult to read it further.
How can we specify the data type as Mule Message Collection ?
Please help me out with this .
Thanks in Advance.
Use MEL expressions to create a collection. Based on your example a comma separated list of strings, you can use MEL with any Java/MVEL operations to create a list from that:
<mock:then-return payload="#[Arrays.asList(('${mycommaseparatedlistofstrings}'.split(',')))]" />
I'm getting crazy whith this, and I'll appreciate any help....
Is there any way to use the value of payload as a map index?.
something like this:
<logger message = "the value is #[flowVars.MyMap['#[payload]'] doc:name="Logger""/>
Thanks in advance
alf.
Use: #[flowVars.MyMap[payload]]