All values undefined in POST requests

Hello all, I’m brand new to APIs and Postman. I can’t seem to get the data from my POST request to my console.

Copious googling revealed that there are some changes to bodyParser that could be the problem, but I believe I have current/valid code for that now.

My request:

My app.js (2 screen captures due to length):

This is the result in the database (number 11), which lacks the data I am trying to pass:

It looks like you are trying to assign your values from the body of the request. For example: commonName from req.body.commonName However, from the looks of your request in the postman screenshot you are passing the common name in the request parameters instead of the body.

You can do one of two things to get this to work.
Change the code to assign from req.params.commonName (instead of req.body.commonName)
Leave the code as is. THen, remove all the query params and instead use the body to send the values, like this:

"commonName":"new plant",
"scientificName":"lorem ipsum",
1 Like

Thank you so much for your assistance!

From following your second suggestion, I determined I simply needed to be in the “body” tab rather than the “params” tab when I was entering the key: value pairs.

Thanks again for helping a clueless newcomer!