POST 400 Bad Request Error

When working on the New Sighting section, when I click ‘Create’ I get the following error in Chrome’s Console:

ember.debug.js:32110 Error: Ember Data Request POST returned a 400
Payload (application/vnd.api+json; charset=utf-8)
[object Object]
    at AdapterError.EmberError (ember.debug.js:16572)
    at AdapterError (errors.js:23)
    at Class.handleResponse (rest.js:843)
    at ajaxError (rest.js:1341)
    at Class.hash.error (rest.js:915)
    at fire (jquery.js:3187)
    at Object.fireWith [as rejectWith] (jquery.js:3317)
    at done (jquery.js:8759)
    at XMLHttpRequest.<anonymous> (jquery.js:9123)onerrorDefault @ ember.debug.js:32110trigger @ ember.debug.js:54447(anonymous function) @ ember.debug.js:55696invoke @ ember.debug.js:333flush @ ember.debug.js:397flush @ ember.debug.js:205end @ ember.debug.js:560run @ ember.debug.js:682join @ ember.debug.js:702run.join @ ember.debug.js:21236hash.error @ rest.js:916fire @ jquery.js:3187fireWith @ jquery.js:3317done @ jquery.js:8759(anonymous function) @ jquery.js:9123

I’m not sure how to go about debugging this. The downloaded book solutions don’t contain an app/controllers/sightings/new.js file, but I’ve entered the code as written in the book. If anyone can offer insight on how to go about debugging this error, I would appreciate it!

So, I solved my own problem by poking around the Ember section of the Chrome Dev Tools. Buried in one of the error messages was something about “is-new” param not allowed, which I added to models/sighting.js for the Silver Challenge in Chapter 21. Any idea why this would throw an error, and how to fix it to bring the is-new property back?

This property is not in API. This solution is not in the book and we will be taking out the challenge. The challenge is using the property isNew which is already a property of a model when created but not persisted.

The way to have properties in the Frontend and not in the backend is to change the Serializer for Sightings. You would add a property called “attrs” like so:

import DS from 'ember-data';

export default DS.JSONSerializer.extend({
  attrs: {
    isNew: { serialize: false }