Dataweave Error: You called the function 'Value Selector' with these arguments when converting Excel to JSON
15,640
I found that the problem was that I had not set the MIME type on the File connector to application/xlsx
Once I set this, it worked.
Related videos on Youtube
Author by
user3165854
Updated on June 04, 2022Comments
-
user3165854 almost 2 years
I am using Anypoint 7 and Mule 4.1.
I want to read an Excel (xlsx) file from a folder on my computer and convert it into JSON but I am receiving the error:
You called the function 'Value Selector' with these arguments:
which I think is down to streaming but not sure how to fix it.
Thanks for any help
XML:
<?xml version="1.0" encoding="UTF-8"?> <mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd"> <flow name="testFlow" doc:id="3030b14f-b215-4c85-a6a4-96236516c552" > <scheduler doc:name="Scheduler" doc:id="d0985a96-a23c-4e2c-80ae-d78a9acd938e" > <scheduling-strategy > <fixed-frequency timeUnit="SECONDS"/> </scheduling-strategy> </scheduler> <file:read doc:name="Read xlsx file" doc:id="90b40273-ec58-47de-a48b-9812c52a74ea" path="C:\apps\test-api\src\test\resources\input\myTestExcelFile.xlsx" config-ref="File_Config"> <ee:repeatable-file-store-stream /> </file:read> <ee:transform doc:name="Transform Message" doc:id="36dbec15-6e02-4fdf-8176-025ad7fdce61" > <ee:message > <ee:set-payload ><![CDATA[%dw 2.0 input payload application/xlsx output application/json --- payload.CUSTOMER map ( cUSTOMER , indexOfCUSTOMER ) -> { custId: cUSTOMER."Customer Code" default "", custName: cUSTOMER.Name default "" } ]]></ee:set-payload> </ee:message> </ee:transform> <logger level="INFO" doc:name="Log Message" doc:id="5142b6ff-9d04-4cb2-ba3b-7fec5e52dd9b" message='#[payload]' category="com.test"/> </flow> </mule>
ERROR MESSAGE
ERROR 2018-08-03 11:03:34,628 [[MuleRuntime].cpuLight.02: [test-api].testFlow.CPU_LITE @75c313f3] [event: 0-7a8a0890-9704-11e8-900d-a44cc83a8228] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler: ******************************************************************************** Message : "You called the function 'Value Selector' with these arguments: 1: Binary 2: Name ("CUSTOMER") 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) 5| payload.CUSTOMER map ( cUSTOMER , indexOfCUSTOMER ) -> { ^^^^^^^^^^^^^^^^ Trace: at map (line: 5, column: 1) at main (line: 5, column: 18)" evaluating expression: "%dw 2.0 input payload application/xlsx output application/json --- payload.CUSTOMER map ( cUSTOMER , indexOfCUSTOMER ) -> { custId: cUSTOMER."Customer Code" default "", custName: cUSTOMER.Name default "" } ". Error type : MULE:EXPRESSION Element : testFlow/processors/1 @ test-api:test.xml:21 (Transform Message) Element XML : <ee:transform doc:name="Transform Message" doc:id="36dbec15-6e02-4fdf-8176-025ad7fdce61"> <ee:message> <ee:set-payload>%dw 2.0 input payload application/xlsx output application/json --- payload.CUSTOMER map ( cUSTOMER , indexOfCUSTOMER ) -> { custId: cUSTOMER."Customer Code" default "", custName: cUSTOMER.Name default "" }</ee:set-payload> </ee:message> </ee:transform> (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
XLSX file