0

I'm using Mule Requester to load a CSV file. After the file is loaded, the payload is a byte array, which I store in a flow variable, mycsv. I keep getting an exception.

org.mule.api.MessagingException: Exception while executing: 
    NetIds: flowVars.mycsv map $."My Column Name"   
                        ^
Cannot coerce a :binary to a :array (com.mulesoft.weave.mule.exception.WeaveExecutionException). Message payload is of type: byte[]

Here's my DataWeave code:

%dw 1.0
%output application/java
---
{
    Values: flowVars.mycsv map $."My Column Name"
}

The previous flow element is a choice, so I set the metadata on that to output to a FlowVar with the right name and referenced a sample CSV file, so DataWeave things the variable type is List<Csv>.

How can I read the CSV? Thanks!

2 Answers 2

1

It's because it doesnt know the mimeType of the flowVar because it's not set. Try this before the dataweave transformer:

<set-variable value="#[flowVars.mycsv]" variableName="mycsv" mimeType="application/csv" doc:name="Variable" />

or set the mimeType when you first read the csv.

Sign up to request clarification or add additional context in comments.

Comments

0

This is the first time I found a requirement to put two different formats into one csv file. In order to get the expected result, I prefer to use this trick: Create both expressions and combine them into one simple array, using flatten Add an empty object as line separator

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.