Is anyone know how i could send a json .I am trying above way but is not 
working.Is returning error code 400.But if i copy paste exactly the same 
the url and the JSON 
to POSTMAN it answering normally. 

var https = require('https');
jsonObject = JSON.stringify({
    (data)
});
var postheaders = {
    'Content-Type' : 'application/json',
    Content-Length' : jsonObject.length
};
var optionspost = {
    host : url,
    port : '',
    path : '/',
    method : 'POST',
    headers : postheaders
};
var reqPost = https.request(optionspost, function(res) {
    console.log("statusCode: ", res.statusCode);
    // uncomment it for header details
//  console.log("headers: ", res.headers);
 
    res.on('data', function(d) {
        console.info('POST result:\n');
        process.stdout.write(d);
        console.info('\n\nPOST completed');
    });
});
 
// write the json data
reqPost.write(jsonObject);
reqPost.end();
reqPost.on('error', function(e) {
    console.error(e);
});

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/81060db0-1fa2-4dd7-baa7-7d4e55a2f3ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to