node.jsjmeterhttprequest

Nodejs API testing with Jmeter POST and PUT


I have been trying for quite some time and I have applied the solutions available on StackOverflow.

In my node.js code, I do not receive POST or PUT request body data passed in the jmeter. The following are my configurations for Jmeter and the code snippet. The output is always "undefined"

enter image description here

enter image description here

Here is the Node.js code:

app.post('/testing', (req, res) => {
    console.log(req.body);
    res.sendStatus(200);
});

Output is undefined


Solution

  • I was using

    app.use(bodyParser.urlencoded({ extended: true }))
    

    instead, I was supposed to use

    app.use(bodyParser.json()) 
    

    Thank you @Evert