Hello,
I'm running the following server code to update existing rows of a table. My understanding is that the correct way to do this is to issue a PUT to the rest interface with two query strings: "where" and "operations". When I do a GET with just the "where" clause, everything works the way I would expect it to, but when I add an "operations" clause to update rows matching the "where" query I always get the error shown in the title.
I have created this test case which boils down to where the problem lies. I have created a database with a single collection called "table" that should be open to the public, so the following sample code should work. The schema/rows of the collection can be seen in the attached screenshot.
The code:
var responseBody = {},
requestParams = {},
paramKeys = request.keys();
for (var key = 0; key < paramKeys.length; key++) {
requestParams[paramKeys[key]] = request.get(paramKeys[key]);
}
// Declare database ID
var dbId = "53e996efe4b0e68a8dbfbc3a";
try {
var XHRResponse = XHR.send("PUT", "https://api.appery.io/rest/1/db/colle...", {
"headers": {
"X-Appery-Database-Id": dbId,
"Content-Type":"application/json"
},
"parameters": {
"operations" : '{"$set":{"toggle":true}}',
"where": '{"name":"one"}'
}
});
if (XHRResponse.status != 200) {
responseBody.message = "message: " + XHRResponse.body + "\ncode: " + XHRResponse.status;
console.log(XHRResponse.body);
response.error(responseBody, "application/json");
} else {
console.log("Success: " + JSON.stringify(XHRResponse.body[0]));
response.success();
}
Am I missing something obvious? The error code that I'm getting doesn't seem to be documented anywhere and all the posts in this forum with the same error code seem to be completely unrelated to my problem.
I have to use the REST API to the DB instead of the nicer javascript hooks because in my application the task I am doing requires the master key. FYI this script can be called via rest at: https://api.appery.io/rest/1/code/0a1...