WP-API + JS Backbone client - how to update post meta
Using the WP API and Backbone-based JS client, I'm trying to update a post's metadata as follows:
var parentId = 96; // the post id
var metaData = new wp.api.collections.PostMeta('', {parent: parentId});
metaData.fetch()
.done(function(data) {
var someKey = data.findWhere({key: 'someKey'});
someKey.set('value', 'newValue');
someKey.save();
});
Everything works fine until the calling of save(), which throws the following error:
PUT http://example.org/wp-json/wp/v2/posts/undefined/meta/1901 404 (Not Found)
Trying to sync the collection also fails.
Any thoughts? Thanks!