Calling API from post process


how to create record in post process script ?

I am trying to add a record to employee table after user register
and I was able to build record with fields required for employee entry in

var record = {
has valid fields // i have tested it using client side api call.

  var result ="mysql/_table/employee", {resource: [record]});
  if (result.status_code !== 200) {
      throw new Error(JSON.stringify(result.content.error.message));

this is throwing some wired error in console log,

any idea how do I call post method from scripting ?


Vinod, what is the error?


looks like it was known issue in 2.2 to call api’s from node script. (FYI, it was logging actually api function instead of executing it)

after upgrade I am still having issue, here is the code i am using"mysql/_table/employee",{resource : [record] }, '', function(body, response){
            console.log(response.statusCode + " " + response.statusMessage);
            event.setResponse(JSON.parse(body), response.statusCode, 'applicaton/json');

above code is giveing me 400 Bad Request in the log and that’s all it says it doesn’t say anything else like invalid path or parameters. I got the above example from

any idea how to call api from node script ?


Bad request means the api call is formatted incorrectly (usually the payload.) I can’t see the rest of your script, but assuming record is a variable:
this: {resource : [record] }
should be this: {"resource" : [record] }