Formula - base64encode
The base64encode Formula function returns the base64 representation of text, encoded to bytes with UTF-8 or with the input encoding you name.
Syntax
base64encode(content [, 'input encoding'])
Parameters
| Parameter | Required | Description |
|---|---|---|
content |
Yes | The text to encode: body, context, or the result of another function, such as jsonPath. |
'input encoding' |
No | The character encoding used to turn the text into bytes before base64 encoding, such as 'UTF-8' or 'iso-8859-1'. Without it, UTF-8 is used. |
Returns
The base64 text. When the content holds several values, for example from jsonPath, each value is encoded and returned as its own Search Field value. When the content has no value, nothing is returned.
Examples
Example 1: Encode the message body
Input
Nodinite
Formula
base64encode(body)
Result
Tm9kaW5pdGU=

Plain ASCII text gives the same base64 result in UTF-8 and ISO-8859-1.
Example 2: Encode text as ISO-8859-1
Input
Skellefteå
Formula
base64encode(body, 'iso-8859-1')
Result
U2tlbGxlZnRl5Q==

With ISO-8859-1, å is the single byte E5. With the default UTF-8, the result is U2tlbGxlZnRlw6U= instead.
Example 3: Encode a context property
Input
| Key | Value |
|---|---|
id |
Simple |
Formula
base64encode(context('id'))
Result
U2ltcGxl

The value of the context property id is encoded; the message body isn't used.
Example 4: Encode several values from a JSON body
Input
[
{ "name": "Hello" },
{ "name": "World" }
]
Formula
base64encode(jsonPath('$..name',body))
Result
SGVsbG8=
V29ybGQ=

jsonPath returns two values, and base64encode encodes each one: two unique matches.
Notes
- Pick the input encoding the receiving system expects. Characters outside ASCII, such as
å,ö, andé, give different base64 results in UTF-8, ISO-8859-1, and Windows-1252. - Encoding names follow .NET; see the List of encodings.