title: Unable to POST values by Postman Body form-data using Node API
body: <p>I am using the following user controller to insert user using Node Express and MongoDB. When I started to insert values using Postman Body form-data, I am getting the following output as error_message "Invalid request, Invalid 'name' parameter." This error says that I want to insert value for name fiels in the Schema, but I entered the name field and its value in the Body form-data as Key and value, So why this did not work?</p>
  
  <p><strong>userController.js</strong></p>
  
  <pre><code>const express=require("express");
  const router =express.Router();
  const mongoose=require("mongoose");
  const multer = require('multer');
  var assert = require('assert');
  const User = require('../models/user.model.js');
  var jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens
  var bodyParser = require('body-parser');
  
  var app = express(); // define our app using express
  
  // Put these statements before you define any routes.
  app.use(bodyParser.urlencoded());
  app.use(bodyParser.json());
  
  // POST
  exports.create = ("/",(req, res, next) =&gt; 
  {
      var varName= req.body.name;
      var varUname = req.body.username;
      var varPass = req.body.password;
      var varEmail = req.body.email;
  
      if(!varName) 
      {
          return res.status(400).send(
              {
                  "error_message": "Invalid request, Invalid 'name' parameter.",
                  "status": "INVALID_REQUEST"
              } 
          );
      }
  
      // Other Validations are go here...
  
      const user = new User(
      {
          name: varName, //required
          address: req.body.address, 
          logo: req.body.logo, 
          username: varUname,  //required
          password: varPass,   //required
          phone_number: req.body.phone_number, 
          email: varEmail,  //required
          token_key : token
      });
  
      // Save Programe in the database
      user.save()
      .then(data =&gt; {
          res.send(
          {
              "error_message": [],
              "results":"User created successfully",
              "status": "Success",
              "token": token
          });
      }).catch(err =&gt; {
          res.status(500).send({
              error_message: err.message || "Some error occurred while creating the Programe."
          });
      });
  });
  
  // GET all
  exports.findAll = (req, res) =&gt; 
  {
      User.find()
      .then(users =&gt; {
          res.send(users);
      }).catch(err =&gt; {
          res.status(500).send({
              error_message: err.message || "Some error occurred while retrieving programe."
          });
      });
  }; 
  </code></pre>
  
  <p>UPDATED, Please see my added <code>server.js</code> code</p>
  
  <pre><code>var express = require("express");
  var app = express();
  var bodyParser = require('body-parser');
  var mongoose = require('mongoose');
  var session = require('express-session');
  
  // Configuring the database
  const dbConfig = require('./config/database.config.js');
  
  var multer = require('multer');
  
  mongoose.Promise = global.Promise;
  
  // Connecting to the database
  mongoose.connect(dbConfig.url)
  .then(() =&gt; {
      console.log("Successfully connected to the database");    
  }).catch(err =&gt; {
      console.log('Could not connect to the database. Exiting now...');
      process.exit();
  });
  
  app.use('/uploads', express.static('uploads'));
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  
  app.use((req, res, next) =&gt; {
    res.header("Access-Control-Allow-Origin", "*");
    res.header(
      "Access-Control-Allow-Headers",
      "Origin, X-Requested-With, Content-Type, Accept, Authorization"
    );
    if (req.method === "OPTIONS") {
      res.header("Access-Control-Allow-Methods", "PUT, POST, PATCH, DELETE, GET");
      return res.status(200).json({});
    }
    next();
  });
  
  // define a simple route
  app.get('/', (req, res) =&gt; {
      res.json({"message": "Welcome to Agenda APP created by ApptimusTECH."});
  });
  
  require('./app/routes/programe.routes.js')(app);
  require('./app/routes/user.routes.js')(app);
  require('./app/routes/agenda.routes.js')(app);
  
  // listen for requests
  app.listen(3000, () =&gt; {
      console.log("Server is listening on port 3000");
  });
  </code></pre>