"Bad POST 400 request" error while updating parse.com table

When I try to update the table on parse.com using the JS SDK, I get the error "POST 400 bad request".

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 do not see how this differs from the example code provided by parse here

+7
source share
3 answers

The sample code that you reference creates all of its parameters before setting up the save () method. This is the step you are missing; you need to create the activeArtworks parameter in your gallery instance. Your update does not work because you are trying to update a property that has never been created.

I would expect this code to work, although I have not tested it, because parse.com requires you to set up an account to run any code, which is stupid, and I did not want to create it:

 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 is also possible to check if there is any information in the 400 error headers (the debug console in your browser displays them on the "Network" tab). I would expect Parse to provide you with some information that will help you debug problems, and that the only place it would put for an HTTP error.

+4
source

If you used the user.logIn (callback) function with Parse JS, your session may be invalid. Check the error code of the callback function, if error.code==209 (invalid session token), use Parse.User.logOut() and log in again.

Like this:

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

I had the same problem, and it was solved after realizing that the type of data I sent was different from the one specified in the columns that I created. In my case, I tried to save the object when I set the array when creating the column in the class.

0
source

All Articles