Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
Postman unable to send request body to express application

I am making a simple post request as follows:

app.post('/', (req, res) => {
  return res.status(200).json(req.body)
})

When I give a post request through postman, nothing comes up its just an empty {}. Here is server.js:

const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const passport = require("passport");
const app = express();
// Bodyparser middleware


const users = require("./routes/api/users");

 
app.use(
  bodyParser.urlencoded({
    extended: true
  })
);
app.use(bodyParser.json());
// DB Config
const db = require("./config/keys").mongoURI;
// Connect to MongoDB
mongoose
  .connect(
    db,
    { useNewUrlParser: true }
  )
  .then(() => console.log("MongoDB successfully connected"))
  .catch(err => console.log(err));


// Passport middleware
app.use(passport.initialize());
// Passport config
require("./config/passport")(passport);
// Routes
app.use("/api/users", users);

const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Server up and running on port ${port}`));

app.post('/', (req, res) => {
  return res.status(200).json(req.body)
})

And here is the Postman snippet: enter image description here

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Your POST body is empty. You are are using query params in your post request. Click on the Body tab in Postman and add your request body there.

{
  "name": "abcxyz",
  "age" : 92
}

over 4 years ago · Santiago Trujillo Report

0

You are using query parameters

?name=abcxyz&age=69

In your example you can access these in express by using req.query:

app.post('/', (req, res) => {
   return res.status(200).json(req.query)
})
over 4 years ago · Santiago Trujillo Report

0

In requests there are a couple of ways to pass data, popular two are:

  1. Query params (the ones you passed through Postman) - these parameters are added to your URL while making the request to the server(making it fit for some use cases and not so much for others), you can access those in the backend using req.query.

    app.post('/', (req, res) => {
      return res.status(200).json(req.query)
    });
    
  2. Request Body (the way you're trying to access currently) - to pass those through Postman you'd normally want to pass in JSON format on the "body" tab. you can access those using req.body in your backend.

    app.post('/', (req, res) => {
      return res.status(200).json(req.body)
     });
    
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!