MuleSoft · DataWeave

Text plain writer is unable to write Array

Short answer

Text plain writer is unable to write Array means the script has no output format, so DataWeave inferred plain text and cannot write the array the script returns. Declare an output format that supports arrays.

VerifiedLast verified

01Error text

MuleSoft error
Text plain writer is unable to write Array.

02Likely causes

  • No output format is set, so the plain-text writer was inferred.
  • The script returns an Array, which the plain-text writer cannot write.

03How to fix it

  1. Add an explicit output directive to the script.
  2. Use a format that can hold an array. The docs' example is output application/java --- payload splitBy ' '.
  3. Run the script again.

iNotes

The docs show the same kind of mismatch for multipart output, with a message that ends but got Array, while writing MultiPart. and the fix output application/json --- dw::core::Objects::keySet(payload.parts).

04Official documentation

Test every fix in a non-production environment before you apply it to production. See how entries are verified.

More for MuleSoft work:Open MuleSoft jobsMuleSoft rates and salariesHire a senior MuleSoft developer

The iPaaS Brief

Subscribe to The iPaaS Brief.

The iPaaS newsletter for the people who run integrations. From iPaaS Group.

Free. You finish on theipaasbrief.com and confirm by email.