Capture Body to Hapi Js

Hi :slight_smile:

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 :slight_smile:

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

@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:

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.