'POST 400 bad request' error when updating parse.com table

javascript, parse-platform

Solution

The sample code you reference creates all of its parameters before setting up the save() method. This is the step you're missing; you need to create the activeArtworks parameter on your gallery instance. Your update is failing because you're trying to update a property that was never created.

I would expect this code to work, though I didn't test it because parse.com requires you to set up an account to run any code, which is silly, and I didn't feel like creating one:

var Gallery = Parse.Object.extend("Gallery");
var gallery = new Gallery();
var activeArtworks = 0;
gallery.activeArtworks = []; // or some more appropriate default if you have one.
gallery.save(null, {
    success: function(gallery) {
        gallery.set("activeArtworks", activeArtworks);
        gallery.save();
    }
});

It might also be worth checking if there's any info in the headers of the 400 error (the debug console in your browser will show these in its Network tab). I would expect Parse to give you some sort of information to help you debug issues, and that's the only place it would fit for an HTTP error.

Problem

I am getting a 'POST 400 bad request' error when trying to update a table on parse.com using JS SDK. ``` var Gallery = Parse.Object.extend("Gallery"); var gallery = new Gallery(); var activeArtworks = 0; gallery.save(null, { success: function(gallery) { gallery.set("activeArtworks", activeArtworks); gallery.save(); } }); ``` Please help! I can't see how this is any different to the sample code provided by parse here

Original source