Creating record with RESTAdapter fails, but how do I find out what the problem is?

Hi, all.

Here’s my request and the response from my server:

Remote Address:192.168.59.103:8080
Request URL:http://192.168.59.103:8080/api/notifications
Request Method:POST
Status Code:201 Created

Request Headers view source

Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:512
Content-Type:application/json; charset=UTF-8
DNT:1
Host:192.168.59.103:8080
Origin:http://192.168.59.103:9000
Referer:http://192.168.59.103:9000/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36

Request Payload view parsed

{"notification":{"status":"testing","date_opened":null,"time_opened":null,"date_closed":null,"time_closed":null,"subsystem_affected":null,"who_resolved_it":null,"who_sent_it":null,"reason":null,"impact":null,"resolution":null,"description_of_problem":"testing","downtime_date_begin":null,"downtime_time_begin":null,"number_of_days":null,"number_of_hours":null,"number_of_minutes":null,"downtime_date_end":null,"downtime_time_end":null,"notification_number":null,"begin_user":null,"end_user":null,"subject":null}}

Response Headers view source

Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, x-requested-with, Accept
Access-Control-Allow-Methods:POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Origin:*
Content-Length:0
Content-Type:text/plain; charset=utf-8
Date:Tue, 07 Oct 2014 19:58:39 GMT
Location:http://192.168.59.103:8080/api/notifications/11
ConsoleSearchEmulationRendering

Here’s the function that I’m calling if saving the new record fails:

function failure(err) {
  console.log("Oops!");
  console.log(err);
}

This outputs an object on the console, but I can’t figure out what the problem is. As you can see from the server response above, the headers and HTTP status code seem to be correct per JSON:API — Latest Specification (v1.0) .

And here’s the line where I try to save the new “notification” model:

notification.save().then(afterSaving, failure);

I don’t no if this is your problem but OPTIONS is where CORS starts. So I think it should not be in Access-Control-Allow-Methods

Thanks, @broerse. Apparently, the problem was that the response to the POST request did not contain the newly created object in its body, despite this reference saying it is unnecessary to do so:

http://jsonapi.org/format/#crud-creating-responses-201