I am trying to make a simple DB based backbone/marionette app which is connected to python eve rest api. After showing a model(title,content) in a form , I edit the content and save it with following:
this.model.save({title:t_title,content: t_content},{ headers: {'If-Match' : this.model.get("_etag")}});
t_title and t_content are the values/inputs from text fields.
When I hit save button and call above code I get 200 OK for PUT but response returned is following error and no update happens in the DB:
{"_status": "ERR", "_issues": {"_updated": "unknown field", "_created": "unknown field", "_id": "unknown field", "_links": "unknown field", "_etag": "unknown field"}}
What else do I need to do this update?
The problem is that when you call save()
it sends all model fields, but seems your server side doesn't save all model fields and accept only two fields (title
and content
). For this case we may use patch: true
option it will get an HTTP PATCH request to the server with just the passed-in attributes.
This is fixed code with patch: true
added in options.
this.model.save({title:t_title,content: t_content},{ patch: true, headers: {'If-Match' : this.model.get("_etag")}});