if you tried one of these error 40s (self-inflicted), this is hopefully a quick resolve for you :)
If you have a javascript webscript controller which uses JSON to communicate, remember to have 'json' in the webscript name, otherwise you do not get the 'magic' JSON object.
'testscript.post.js' (does not have a root object called 'json')
'testscript.post.json.js' (does)
You could also use the following start of the webscript (parsing the input data manually)
// Check we have a json request
if (typeof json === "undefined") {
json = jsonUtils.toObject(requestbody.content);
if (typeof json === "undefined") {
if (logger.isWarnLoggingEnabled() == true) {
logger.warn("Could not run webscript, because json object was undefined.");
}
status.setCode(501, "Could not run webscript, because json object was undefined.");
return;
}
}
No comments:
Post a Comment