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

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


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.


If you had use user.logIn(callback) function with Parse JS, maybe your session invalid. Please check your callback function error code, if error.code==209 (invalid session token), use Parse.User.logOut() and re-login again.

Like this:

if (error.code == 209) {    
    Parse.User.logOut();
    user.logIn(loginCallback);
    return;
}

I had this same issue and it was resolved after realising that the data type that I was posting was different to that specified in the columns that I had created. In my case, I was trying to save an object when I had specified an array when creating the column in the class.

链接地址: http://www.djcxy.com/p/65224.html

上一篇: 使用CL寄存器进行移位会导致寄存器部分失速?

下一篇: 更新parse.com表时发生'POST 400错误请求'错误