---
title: "Formula - body: Read the Message Body of a Log Event"
description: The body Formula function returns the whole message body (payload) of a Log Event as text. Use it on its own or as the content of xPath, jsonPath, regex, and other Formula functions in Search Fields.
---

# :fa-function: 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)][hero]  
*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`.*  

## :fa-code: Syntax

```text
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][]).

## :fa-list-ol: Examples

### Example 1: Return the whole XML order

#### Input

```xml
<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

```text
body
```

#### Result

```xml
<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)][1]  
*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](#example-1-return-the-whole-xml-order).

#### Formula

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

#### Result

```text
New York
```

![Test Expression tab: xpath('Orders/Order/City', body) returns New York (7.12)][ex2]  
*`body` hands the whole payload to `xpath`, which returns the one City value; the `ns0` prefix needs no namespace declaration in the path.*  

## :fa-circle-info: 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][Endpoints], or [Message Type][Message Types]) before any [Search Field Expression][Search Field Expressions] 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][].

## :fa-hand-point-right: Next Steps

* :fa-magnifying-glass-plus: [Add or manage Search Field][]  
* :fa-flask: [Test Your Expression][]  
* :fa-hard-drive: [Add or manage Log View][]  

## :fa-link-horizontal: Related Topics

* :fa-key: [context][Context]  
* :fa-tags: [contextKey][]  
* :fa-table-list: [field][]  
* :fa-function: [Formula][]  
* :fa-scroll: [Formula language rules][]  
* :fa-puzzle-piece: [Search Field Expressions][]  
* :fa-envelope: [Log Event][]  
* :fa-language: [Character Encoding][]  

[1]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Source/Body.png

[Add or manage Log View]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/Add%20or%20Manage%20Log%20View.md
[Add or manage Search Field]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md
[base64decode]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Convert/base64decode.md
[Character Encoding]:{ndr}/Core%20Services/Log%20Event/Features/Character%20Encoding.md
[Context]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/context.md
[contextKey]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/contextKey.md
[Endpoints]:{ndr}/Repository%20Model/Endpoints/Overview.md
[ex2]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Source/body_Example2.png
[field]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/field.md
[Formula]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md
[Formula language rules]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md#fa-scroll-formula-language-rules
[hero]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Source/Formula_Body.gif
[jsonPath]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/jsonPath.md
[Log Event]:{ndr}/Core%20Services/Log%20Event/Overview.md
[Logging Service]:{ndr}/Core%20Services/Logging%20Service/Overview.md
[Message Types]:{ndr}/Repository%20Model/Message%20Types/Overview.md
[Order-to-Cash demo]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/Generate-O2C-Demo-Data.md
[regex]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/regex.md
[Search Field Expressions]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Overview.md
[Test Your Expression]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md#test-your-expression
[xPath]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/xPath.md