- 2 minutes to read

Formula - Body

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

Read the whole message body of an Order-to-Cash event with body, then pick the customer name out of it with xPath, animated walkthrough (7.12)
Animated walkthrough: on the logged XML Order Entry of order ORD-10005 in the Order-to-Cash demo, body returns the complete payload as one value, and xPath('OrderEntry/Customer/CustomerName', body) returns Tailspin Toys.

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>

Test Expression tab: body returns the whole XML order as one unique match (7.12)
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

Test Expression tab: xpath('Orders/Order/City', body) returns New York (7.12)
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