close

  
<p> function error(msg) {
  acre.response.status = 400;
  var result = {
    "code": "/api/status/error",
    "status" : "400 Bad Request",
    "message" : msg
  };
  acre.write(JSON.stringify(result,null,2)); 
  acre.exit();
}


var rabj = acre.require('/freebase/libs/rabj/lib','release');
var user = acre.freebase.get_user_info();

if (user == null) error("The user must be logged in to be able to execute this request");
if (acre.request.method != "POST") error("This script only support POST");

var id = acre.request.body_params.id;
var questions = JSON.parse(acre.request.body_params.questions);

if (!id || id == "") error("Must specify the 'id' parameter and it must be non-empty");
if (!(questions instanceof Array)) error("'questions' parameter must contain an array JSON object");

var result = rabj.add_questions(id, questions);

var response = {
  "code": "/api/status/ok",
  "status" : "200 OK",
  "result" : result
};
             
acre.response.status = 200;
acre.response.set_header("content-type", "application/json");
acre.write(JSON.stringify(response, null, 2));
  



 </p>

Comments

Hide