title: Meteor MongoDB - cant insert _id with _id from API call
body: <p>I am trying to call the TwitchAPI and insert some of the returned data into MongoDB. However, every time I get this error: <code>Error: Meteor requires document _id fields to be non-empty strings or ObjectIDs</code>.</p>
  
  <p>The Twitch API response for a single stream/channel looks like this:</p>
  
  <pre><code>{
    "streams": [
      {
        "_id": 11220687552,
        "game": "League of Legends",
        "viewers": 11661,
        "created_at": "2014-09-30T01:10:36Z",
        "_links": {
          "self": "http://api.twitch.tv/kraken/streams/mushisgosu"
        },
        "preview": {
          "small": "http://static-cdn.jtvnw.net/previews-ttv/live_user_mushisgosu-80x50.jpg",
          "medium": "http://static-cdn.jtvnw.net/previews-ttv/live_user_mushisgosu-320x200.jpg",
          "large": "http://static-cdn.jtvnw.net/previews-ttv/live_user_mushisgosu-640x400.jpg",
          "template": "http://static-cdn.jtvnw.net/previews-ttv/live_user_mushisgosu-{width}x{height}.jpg"
        },
        "channel": {
          "_links": {
            "self": "https://api.twitch.tv/kraken/channels/mushisgosu",
            "follows": "https://api.twitch.tv/kraken/channels/mushisgosu/follows",
            "commercial": "https://api.twitch.tv/kraken/channels/mushisgosu/commercial",
            "stream_key": "https://api.twitch.tv/kraken/channels/mushisgosu/stream_key",
            "chat": "https://api.twitch.tv/kraken/chat/mushisgosu",
            "features": "https://api.twitch.tv/kraken/channels/mushisgosu/features",
            "subscriptions": "https://api.twitch.tv/kraken/channels/mushisgosu/subscriptions",
            "editors": "https://api.twitch.tv/kraken/channels/mushisgosu/editors",
            "videos": "https://api.twitch.tv/kraken/channels/mushisgosu/videos",
            "teams": "https://api.twitch.tv/kraken/channels/mushisgosu/teams"
          },
          "background": null,
          "banner": "http://static-cdn.jtvnw.net/jtv_user_pictures/mushisgosu-channel_header_image-c5c08cce281b7be3-640x125.jpeg",
          "display_name": "MushIsGosu",
          "game": "League of Legends",
          "logo": "http://static-cdn.jtvnw.net/jtv_user_pictures/mushisgosu-profile_image-b1c8bb5fd700025e-300x300.png",
          "mature": false,
          "status": "CLG hi im Gosu - Challenger AD - Smurfing Master!",
          "partner": true,
          "url": "http://www.twitch.tv/mushisgosu",
          "video_banner": "http://static-cdn.jtvnw.net/jtv_user_pictures/mushisgosu-channel_offline_image-7e3401b20cb5d739-640x360.png",
          "_id": 41939266,
          "name": "mushisgosu",
          "created_at": "2013-03-31T21:12:14Z",
          "updated_at": "2014-09-30T03:08:55Z",
          "abuse_reported": null,
          "delay": 60,
          "followers": 318914,
          "profile_banner": null,
          "profile_banner_background_color": null,
          "views": 25963780,
          "language": "en-us"
        }
      }
    ],
    "_total": 8477,
    "_links": {
      "self": "https://api.twitch.tv/kraken/streams?limit=1&amp;offset=0",
      "next": "https://api.twitch.tv/kraken/streams?limit=1&amp;offset=1",
      "featured": "https://api.twitch.tv/kraken/streams/featured",
      "summary": "https://api.twitch.tv/kraken/streams/summary",
      "followed": "https://api.twitch.tv/kraken/streams/followed"
    }
  }
  </code></pre>
  
  <p>The part of my server method that tries to insert the data </p>
  
  <pre><code>            Meteor.call('getStreams', function(err, res) {
                  var data = res.data.streams;
                  console.log(data);
                  data.forEach(function(item) {
                      console.log(item._id);
                      Streams.insert({
                          _id: item._id,
                          title: item.channel.status,
                          author: item.channel.display_name,
                          url: item.url
                      });
                  });
              });
  </code></pre>
  
  <p>getStreams simple defines the url to call and sets some variable. As you can see I am console logging the expected <code>_id</code> so I know it is returning a valid string but I am still getting the error. Currently, when I make the call I return 100 streams at a time and iterate through them to save the 4 fields above. Ideally, I would like to save each stream object as its own entry in the DB but all my attempts to do that have resulted in the same error and I also read somewhere that the version on "miniMongo" bundled with Meteor does not support inserting an array of objects in bulk...I also have read that miniMong does not support <code>Collection.save()</code> so sadly I think it will be more later to update the contents of each <code>_id</code> with the latest API call info since I cant just use <code>.save</code> to update and insert in the same statement.</p>
  
  <p>I am not sure if it has any impact but I did try setting <code>autoIndexId</code> to <code>false</code> when creating the collection and it doesn't seem to matter:</p>
  
  <p><code>Streams = new Meteor.Collection('streams', {autoIndexId: false});</code></p>
  
  <p>Any insight is appreciated.</p>