# I need to get the RAW body from a listener node

**URL:** <https://discourse.nodered.org/t/i-need-to-get-the-raw-body-from-a-listener-node/3105>\
**Category:** General\
**Created:** [13 September 2018 09:10 UTC](https://discourse.nodered.org/t/i-need-to-get-the-raw-body-from-a-listener-node/3105 "2018-09-13T09:10:32Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![chrisnie](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@chrisnie](https://discourse.nodered.org/u/chrisnie)\
**Post date:** [24 October 2018 08:07 UTC](https://discourse.nodered.org/t/i-need-to-get-the-raw-body-from-a-listener-node/3105/19 "2018-10-24T08:07:13Z")

</div>

Hi @stefanopog,

i had some time digging into it and now it might i've found a solution by picking up @shrickus hint with the `httpNodeMiddleware`.

In the first tests with the `httpNodeMiddleware` I discovered that the request already has ben parsed at this point. So I started tracking down where it got parsed and found it: It seems to be a default handler from the admin-UI at this point:

> <https://github.com/node-red/node-red/blob/9d219c163df67c0acab7868e2f45aea65d8fe879/red/api/index.js#L42>

  
After discovering this line 36 gave me the right hint: We just get the admin UI away form the default path by setting something like `httpAdminRoot: '/admin',` in `settings.js` and voila - the request is unparsed in `httpNodeMiddleware`.

As next step I've created an own jsonParser setting me the raw body. I've also placed this code into `settings.js` just before the `module.exports = {` line:

```auto
var bodyParser = require('body-parser');
var jsonParserWithRawBody = bodyParser.json({
    verify: function (req, res, buf, encoding) {
        req.rawBody = buf;
    }
})

```

This parser stores the body into `req.rawBody` for later usage...

some lines down in `settings.js` i've commented in the httpNodeMiddleware and conditionally added my parser:

```auto
    httpNodeMiddleware: function(req,res,next) {
        if (req.url === '/my/httpin/url/where/i/want/to/have/the/raw/body') {
           jsonParserWithRawBody(req, res, next);
        } else
           next();
    },

```

Now i have the rawBody for my httpin to do all my authentication stuff...

Cheers, Chris

---

_[View the full topic](https://discourse.nodered.org/t/i-need-to-get-the-raw-body-from-a-listener-node/3105)._
