- 2 minutes to read

Formula - Body

The body Formula function returns the whole message body (payload) of the Log Event as text.

Syntax

body

Parameters

Parameter Required Description
(none) – body takes no parameters and is written without parentheses.

Returns

The complete message body as one text value. Use body as the Content argument of another function, such as xPath, jsonPath, or regex, to pick values out of the payload (see Formula language rules).

Examples

Example 1: Return the whole XML order

Input

<ns0:Orders xmlns:ns0="SupplyChain.Schemas/1.0">
  <Order>
    <Id>1337</Id>
    <Amount>666</Amount>
    <City>New York</City>
    <Partner>QWNtZQ==</Partner>
  </Order>
</ns0:Orders>

Formula

body

Result

<ns0:Orders xmlns:ns0="SupplyChain.Schemas/1.0">
  <Order>
    <Id>1337</Id>
    <Amount>666</Amount>
    <City>New York</City>
    <Partner>QWNtZQ==</Partner>
  </Order>
</ns0:Orders>

Formula body expression returning the whole XML order message in the Test Expression tab
The body formula returns the complete message body as one unique match.

Example 2: Use the body as content for xPath

Input

The same XML order as in Example 1.

Formula

xpath('Orders/Order/City', body)

Result

New York

Formula xpath on the body returning the City value New York in the Test Expression tab
body hands the whole payload to xpath, which returns the one City value; the ns0 prefix needs no namespace declaration in the path.

Notes

  • body() with parentheses is not the documented form; write body.
  • Functions that parse the whole message body, such as xPath or regex, take longer on large payloads; keep the formula as specific as the job allows.
  • The Logging Service decodes the body with its resolved Character Encoding (Log Event, Endpoint, or Message Type) before any Search Field Expression runs, so body is already text in the right characters. A body logged as base64 can be decoded there with a Base64 Decode into … encoding, or in the formula with base64decode.

Next Steps