Calling API from script using node


#1

Hi,
how to call post api from script using node.
below code is give me > 400 Bad Request

           platform.api.post("mysql/_table/employee",{"resource": [payload]}, '', function(body, response){
                    console.log(response.statusCode + " " + response.statusMessage);
                    event.setResponse(JSON.parse(body), response.statusCode, 'applicaton/json');
                });

any idea how to call api from script and what am I doing wrong ?


#2

any know how to call api from node event scripit ?
example for df wiki is notworking
Thanx


#3

@Vinod_Hum

You do have a typo in your code:

event.setResponse(JSON.parse(body), response.statusCode, 'applicaton/json');

It should be:

event.setResponse(JSON.parse(body), response.statusCode, 'application/json');

You forgot an ā€œiā€ in application.