# Saving a new record, how should JSON API response look like?

**URL:** <https://discuss.emberjs.com/t/saving-a-new-record-how-should-json-api-response-look-like/10162>\
**Category:** Ember Data\
**Created:** [March 15, 2016, 3:24pm UTC](https://discuss.emberjs.com/t/saving-a-new-record-how-should-json-api-response-look-like/10162 "2016-03-15T15:24:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bauke](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/bauke/32/12190_2.png) [@Bauke](https://discuss.emberjs.com/u/Bauke)\
**Post date:** [March 15, 2016, 3:24pm UTC](https://discuss.emberjs.com/t/saving-a-new-record-how-should-json-api-response-look-like/10162/1 "2016-03-15T15:24:14Z")

</div>

I recently switched to JSON API but I run into trouble when saving a new record. Say I created a record of the model type **foobar** and save it:

```auto
let record = this.get('store').createRecord('foobar', {
  name: 'whheeeeee'
});
record.save().then(function(record) {
  console.log('record saved: ' + record.get('id'));
});

```

And the server reponse looks like this:

```auto
{
  'data': [
    {
      'type': 'foobar',
      'id': 'foobar_id_123'
    }
  ]
}

```

No error of whatsoever, but apparently the response is not synced with the actual record in the store. The ID of the record is still **null**!

It worked in REST. So how do I fix this?

---

<div class="post-metadata">

**Author:** ![vikram7](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/vikram7/32/12393_2.png) [@vikram7](https://discuss.emberjs.com/u/vikram7)\
**Post date:** [March 15, 2016, 3:29pm UTC](https://discuss.emberjs.com/t/saving-a-new-record-how-should-json-api-response-look-like/10162/2 "2016-03-15T15:29:48Z")

</div>

Should `data` be an array? If it’s a single object, I would think it wouldn’t be. Take a look at the example [here](http://jsonapi.org/format/)

```auto
{
  "data": {
    "type": "photos",
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "attributes": {
      "title": "Ember Hamster",
      "src": "http://example.com/images/productivity.png"
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Bauke](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/bauke/32/12190_2.png) [@Bauke](https://discuss.emberjs.com/u/Bauke)\
**Post date:** [March 15, 2016, 3:37pm UTC](https://discuss.emberjs.com/t/saving-a-new-record-how-should-json-api-response-look-like/10162/3 "2016-03-15T15:37:00Z")

</div>

Wow, yeah, that did it. I feel kinda embarrassed, I’d better quit for today. Thanks. 🙂
