Start a new topic

body not sent when use request module with post

Hi,



i'm experiencing issues with the following code in the BL:



function onPreSave(request, response, modules)

{

var req = modules.request;

var logger = modules.logger;

logger.info(request.body);

req.request

(

{

uri: 'http://***/api/export',

method: 'POST',

body : "something" //.stringify(request.body)

},

function(error, res, body)

{

logger.info(arguments);

if (error)

{

response.body = {error: error.message};

response.complete(434);

}

else

{

response.body = JSON.parse(body);

response.complete(res.status);

}

}

);



}



i receive the call in my nodejs server, but when i check the request.body, it says it is undefined..



What am i doing wrong?




You probably need json:true (or Content-Type: application/json header, which is equivalent). Your node.js server does not know how to deserialize the body.
Thanks for the fast reply!



That was indeed the solution, thank you!
Login or Signup to post a comment