title: Node, express, Monk, mongodb: 400 bad request error on post request. Why am I getting this error?
body: <p>I've been trying to get a simple nodejs API with CRUD functionality working. I'm using express, and 'monk' package for communicating with mongodb. I've successfully pulled data with a GET request. </p>
  
  <p>I'm unable to get a post() function to work. I'm able to insert new documents to mongo when the insert request is called from a GET request that inserts a doc every time it's called. However, no matter what I do, with or without an actual insert request, my post is returning a 400. </p>
  
  <p>Here's my route file: </p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  
  /* GET hours page. (for users to submit hours) */
  router.get('/', function (req, res) {
      var db = req.db;
      var collection = db.get('entries');
      collection.find({}, /*{limit:20}, */function (err, docs) {
          if (err) {
              console.log('couldn\'t load entries');
          }
          res.json(docs);
      });
  });
  
  /* POST hours page. (for users to submit hours) */
  router.post('/', function (req, res) {
      if (!(req.body.job || req.body.code || req.body.hours)) {
          handleError(res, 'Invalid user input', 'Must complete input', 400);
      }
      var db = req.db;
      var collection = db.get('entries');
      var newEntry = req.body;
  
      collection.insert(newEntry, function (err, docs) {
          if (err){
              handleError(res, err.message, 'Failed to create new entry');
          }
          res.json(docs);
      });
  });
  
  module.exports = router;
  </code></pre>
  
  <p>I really don't know why ever single post request is returning a 400. I'm thinking it's a problem with my main file, but it has barely been altered from the initial express generated file. </p>