---
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.
---

# <i class="fal fa-function" aria-hidden="true"></i> 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`.*  

## <i class="fal fa-code" aria-hidden="true"></i> 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][]).

## <i class="fal fa-list-ol" aria-hidden="true"></i> 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.*  

## <i class="fal fa-circle-info" aria-hidden="true"></i> 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][].

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

* <i class="fal fa-magnifying-glass-plus" aria-hidden="true"></i> [Add or manage Search Field][]  
* <i class="fal fa-flask" aria-hidden="true"></i> [Test Your Expression][]  
* <i class="fal fa-hard-drive" aria-hidden="true"></i> [Add or manage Log View][]  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

* <i class="fal fa-key" aria-hidden="true"></i> [context][Context]  
* <i class="fal fa-tags" aria-hidden="true"></i> [contextKey][]  
* <i class="fal fa-table-list" aria-hidden="true"></i> [field][]  
* <i class="fal fa-function" aria-hidden="true"></i> [Formula][]  
* <i class="fal fa-scroll" aria-hidden="true"></i> [Formula language rules][]  
* <i class="fal fa-puzzle-piece" aria-hidden="true"></i> [Search Field Expressions][]  
* <i class="fal fa-envelope" aria-hidden="true"></i> [Log Event][]  
* <i class="fal fa-language" aria-hidden="true"></i> [Character Encoding][]  

[1]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Source/Body.png

[Add or manage Log View]:https://docs.nodinite.com/administration/log-management/log-views/features/add-or-manage-log-view/
[Add or manage Search Field]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/
[base64decode]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/convert/base64decode/
[Character Encoding]:https://docs.nodinite.com/core-services/log-event/features/character-encoding/
[Context]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/source/context/
[contextKey]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/source/contextkey/
[Endpoints]:https://docs.nodinite.com/repository-model/endpoints/overview/
[ex2]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Source/body_Example2.png
[field]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/source/field/
[Formula]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/
[Formula language rules]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/#fa-scroll-formula-language-rules
[hero]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Source/Formula_Body.gif
[jsonPath]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/jsonpath/
[Log Event]:https://docs.nodinite.com/core-services/log-event/overview/
[Logging Service]:https://docs.nodinite.com/core-services/logging-service/overview/
[Message Types]:https://docs.nodinite.com/repository-model/message-types/overview/
[Order-to-Cash demo]:https://docs.nodinite.com/repository-model/bpms/examples/order-to-cash/generate-o2c-demo-data/
[regex]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/regex/
[Search Field Expressions]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/
[Test Your Expression]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/#test-your-expression
[xPath]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/xpath/