i want to update the push device registration record using server code.
I made many attempt but ... i was not able to write the correct code.
I got the error "No resource method found for POST"
I enclose here the code and the log trace.
Help me please to find where is my error!
code
/*
deviceReg_Update
*/var responseBody = {},
requestParams = {},
paramKeys = request.keys();
for (var key = 0; key < paramKeys.length; key++) {
requestParams[paramKeys[key]] = request.get(paramKeys[key]);
}// Declare database ID and Master key
var dbId = "554xxxxxxxxxxxx7cb"
var masterKey = "50b4d712-xxxxx-xxxx-xxxx-c6f7d4cf79dc"// Get parameters into vars
var appID = requestParams['appID'];
var deviceID = requestParams['deviceID'];
var userID = requestParams['user_id'];try {
//ricerca deviceID
var devObj = XHR.send("GET", "https://api.appery.io/rest/push/reg/" + deviceID, {
"headers": {
"X-Appery-App-Id": appID,
"Content-Type": "application/json"
}
});
if (devObj.status != 200) {
throw new Error(devObj.body.code + " - " + devObj.body.description);
}
console.log("Original DevObj");
console.dir(devObj);//update device user_id field
var newDevObj = XHR.send("POST", "https://api.appery.io/rest/push/reg/" + deviceID, {
"headers": {
"X-Appery-App-Id": appID,
"Content-Type": "application/json"
},
"body": {
"user_id": userID
}
});
if (devObj.status != 200) {
throw new Error(devObj.body.code + " - " + devObj.body.description);
}console.log("ret value from update:");
console.log(newDevObj);} catch (e) {
console.log(e);
response.error(devObj.body.code);
}/code