# Capture Body to Hapi Js

**URL:** <https://discuss.elastic.co/t/capture-body-to-hapi-js/278450>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [July 12, 2021, 5:52pm UTC](https://discuss.elastic.co/t/capture-body-to-hapi-js/278450 "2021-07-12T17:52:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guimap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guimap/32/90813_2.png) [@guimap](https://discuss.elastic.co/u/guimap)\
**Post date:** [July 12, 2021, 5:52pm UTC](https://discuss.elastic.co/t/capture-body-to-hapi-js/278450/1 "2021-07-12T17:52:08Z")

</div>

Hi 🙂

I'm using nodejs agent with hapi framework, i set up `captureBody` option into config, even with this option enabled my http requests doesnt store payload, after read some issues related with this errors, i discovered that the APM Agent only get body payload when content type header is set to `application/x-www-form-urlencoded`

There`s any way to save the payload into my transactions ?

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 2, 2021, 1:52pm UTC](https://discuss.elastic.co/t/capture-body-to-hapi-js/278450/2 "2021-08-02T13:52:50Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [August 3, 2021, 6:16pm UTC](https://discuss.elastic.co/t/capture-body-to-hapi-js/278450/3 "2021-08-03T18:16:03Z")

</div>

@guimap The agent doesn't disable capturing the incoming request body if the content-type is something other than application/x-ww-form-urlencoded. However, it _does_ get the body value from:

```auto
var body = req.json || req.body || req.payload

```

so it relies on the HTTP framework setting the read body on one of those variables. Is it possible your HAPI server is configured to only parse a response body if it has that content-type?

The agent's handling of this is in `getContextFromRequest` in "node\_modules/elastic-apm-node/lib/parsers.js". Perhaps you could add some debug statements in there to print what the agent is seeing.
