{"action":"created","issue":{"url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/114","repository_url":"https://api.github.com/repos/ga-wdi-boston/group-project","labels_url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/114/labels{/name}","comments_url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/114/comments","events_url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/114/events","html_url":"https://github.com/ga-wdi-boston/group-project/issues/114","id":155062197,"number":114,"title":"CURL error with nested ID","user":{"login":"MichaelB167","id":17414119,"avatar_url":"https://avatars.githubusercontent.com/u/17414119?v=3","gravatar_id":"","url":"https://api.github.com/users/MichaelB167","html_url":"https://github.com/MichaelB167","followers_url":"https://api.github.com/users/MichaelB167/followers","following_url":"https://api.github.com/users/MichaelB167/following{/other_user}","gists_url":"https://api.github.com/users/MichaelB167/gists{/gist_id}","starred_url":"https://api.github.com/users/MichaelB167/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichaelB167/subscriptions","organizations_url":"https://api.github.com/users/MichaelB167/orgs","repos_url":"https://api.github.com/users/MichaelB167/repos","events_url":"https://api.github.com/users/MichaelB167/events{/privacy}","received_events_url":"https://api.github.com/users/MichaelB167/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-05-16T16:06:01Z","updated_at":"2016-05-16T18:28:09Z","closed_at":null,"body":"We're trying to create an order that has an owner that references 'user' and a product ID that references 'product'.  We created an order schema that has an attribute 'lineItems' that the product ID is nested within.  Currently, we're testing this structure via a CURL post request but the object we're trying to convert is returning as null.  Is this most likely a problem with our CURL formatting in terms of structuring lineItems as an array or do we need to revisit our schema structure?  \r\n\r\nOrder model:\r\n```\r\n'use strict';\r\n\r\nconst mongoose = require('mongoose');\r\n\r\nconst orderSchema = new mongoose.Schema({\r\n    _owner: {\r\n       type: mongoose.Schema.Types.ObjectId,\r\n       ref: 'User',\r\n       required: true\r\n     },\r\n     lineItems: [\r\n       {product: {\r\n         quantity: {\r\n           type: Number,\r\n           required: true,\r\n           default: 1\r\n         },\r\n         id: {\r\n           type: mongoose.Schema.Types.ObjectId,\r\n           ref: 'Product',\r\n           required: true\r\n         },\r\n         name: {\r\n           type: String,\r\n           required: true\r\n         },\r\n         price: {\r\n           type: Number,\r\n           required: true\r\n         }\r\n       }\r\n     }]\r\n   },\r\n     {timestamps: true\r\n });\r\n\r\nconst Order = mongoose.model('Order', orderSchema);\r\n\r\nmodule.exports = Order;\r\n```\r\n\r\nOrder controller:\r\n```\r\n'use strict';\r\n\r\nconst controller = require('lib/wiring/controller');\r\nconst models = require('app/models');\r\nconst Order = models.order;\r\n\r\nconst authenticate = require('./concerns/authenticate');\r\n\r\nconst index = (req, res, next) => {\r\n  Order.find()\r\n  .then((orders) => res.json({ orders }))\r\n  .catch((err) => next(err));\r\n};\r\n\r\nconst create = (req, res, next) => {\r\n  let order = Object.assign(req.body.order, {\r\n    _owner: req.currentUser._id\r\n  });\r\n  Order.create(order)\r\n  .then(order => res.json({ order }))\r\n  .catch(err => next(err));\r\n};\r\n\r\nconst show = (req, res, next) => {\r\n  Order.findById(req.currentUser._id)\r\n  .then(order => order ? res.json({ order }): next())\r\n  .catch(err => next(err));\r\n};\r\n\r\nconst update = (req, res, next) => {\r\n  let search = {_id: req.params.id, _owner: req.currentUser._id};\r\n  Order.findOne(search)\r\n  .then(order => {\r\n    if(!order) {\r\n      return next();\r\n    }\r\n\r\n    delete req.body._owner;\r\n    return order.update(req.body.order)\r\n    .then(() => res.sendStatus(200));\r\n  })\r\n  .catch(err => next(err));\r\n};\r\n\r\nconst destroy = (req, res, next) => {\r\n  let search = {_id: req.params.id, _owner: req.currentUser._id};\r\n  Order.findOne(search)\r\n  .then(order => {\r\n    if(!order){\r\n      return next();\r\n    }\r\n\r\n  return order.remove()\r\n  .then(() => res.sendStatus(200))\r\n  .catch(err => next(err));\r\n  });\r\n};\r\n\r\nmodule.exports = controller({\r\n  index,\r\n  create,\r\n  show,\r\n  update,\r\n  destroy\r\n}, {before: [\r\n  {method: authenticate, except: ['index'] },\r\n], });\r\n```\r\n\r\nCURL error:\r\n```\r\n~/wdi/projects/group/nozama-api (orderscrud)$ curl --include --request POST http://localhost:3000/orders \\\r\n>   --header \"Authorization: Token token=wmEF6gt8YIZDFRna2/nyQBpNi0pvCJ4m9PqaTpolCAU=--Pe3aqDn3Wf6Jo+RoXtQAz+96lJ0g/oFfjmD6TJQirp0=\" \\\r\n>   --header \"Content-Type: application/json\" \\\r\n>   --data '{\r\n>         \"product\": {\r\n>           \"quantity\": 1,\r\n>           \"id\": \"5739eb783e7fa5497f620d30\",\r\n>           \"name\": \"The Art of the Deal\",\r\n>           \"price\": 1000000000\r\n>         }\r\n>   }'\r\nHTTP/1.1 500 Internal Server Error\r\nX-Powered-By: Express\r\nAccess-Control-Allow-Origin: http://localhost:8080\r\nVary: Origin\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 77\r\nETag: W/\"4d-mdHX1/4Jmnc5ETXhkY/JmA\"\r\nDate: Mon, 16 May 2016 15:47:33 GMT\r\nConnection: keep-alive\r\n\r\n{\"error\":{\"message\":\"Cannot convert undefined or null to object\",\"error\":{}}}\r\n```"},"comment":{"url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/comments/219505345","html_url":"https://github.com/ga-wdi-boston/group-project/issues/114#issuecomment-219505345","issue_url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/114","id":219505345,"user":{"login":"RDegnen","id":8826469,"avatar_url":"https://avatars.githubusercontent.com/u/8826469?v=3","gravatar_id":"","url":"https://api.github.com/users/RDegnen","html_url":"https://github.com/RDegnen","followers_url":"https://api.github.com/users/RDegnen/followers","following_url":"https://api.github.com/users/RDegnen/following{/other_user}","gists_url":"https://api.github.com/users/RDegnen/gists{/gist_id}","starred_url":"https://api.github.com/users/RDegnen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RDegnen/subscriptions","organizations_url":"https://api.github.com/users/RDegnen/orgs","repos_url":"https://api.github.com/users/RDegnen/repos","events_url":"https://api.github.com/users/RDegnen/events{/privacy}","received_events_url":"https://api.github.com/users/RDegnen/received_events","type":"User","site_admin":false},"created_at":"2016-05-16T18:28:09Z","updated_at":"2016-05-16T18:28:09Z","body":"what does your req object look like?"}}