title: Passing a Mongo ObjectId in a URL and querying that ID with Node/Express
body: <p>I'm having a lot of trouble passing in an objectId as my URL parameter. I know that the ObjectId in MongoDB is a hex value, and that I need to do some conversions, but I'm getting errors with every method I use to do this.</p>
  
  <p>Currently, the error that I'm getting states, "Argument passed in must be a single String of 12 bytes or a string of 24 hex characters."</p>
  
  <pre class="lang-js prettyprint-override"><code>var mongo   = require('mongodb').MongoClient;
  var ObjectID = require('mongodb').ObjectID;
  
  
   app.get('/characters/:id', function (req, res) {
     console.log(req.params.id);
     var collection = db.collection('Character');
     _id = new ObjectID(req.params.id);
   });
  </code></pre>
  
  <p>The request I'm passing is:</p>
  
  <pre><code>address/characters/:565dffa7463e4c60b1166f43
  </code></pre>
  
  <p>Thanks for any help on this.</p>