Skip to content

Instantly share code, notes, and snippets.

@808codist
Last active March 21, 2021 19:36
Show Gist options
  • Save 808codist/595053d5da8e635a326ebd67565b416a to your computer and use it in GitHub Desktop.
Save 808codist/595053d5da8e635a326ebd67565b416a to your computer and use it in GitHub Desktop.
Mule Dataweave Cookbook

only one so far... :-)

base-64 binary encode/decode

%dw 2.0
output application/json
import * from dw::core::Binaries
var mime = 'application/json'
var og = {foo:'bar'}
var str = toBase64(write(og,mime) as Binary)
var bin = str as Binary {base:'64'}
---
{
    str:str,
    bin:bin,
    back:read(bin, mime)
}
  • when mocking anypoint-mq:publish returned payload, set mediaType to application/octet-stream
  • works in this playground
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment