convert curl -F request to nodejs request convert curl -F request to nodejs request curl curl

convert curl -F request to nodejs request


This post helped me out: http://stackoverflow.com/questions/19818918/nodejs-sending-uploading-a-local-file-to-a-remote-server

var POST_DATA = 'data={[' was changed to: var POST_DATA = 'document={['

I dodn't even have to write to file and post postData json code

Here is full working code:

var http = require('http');var postData = { id: "12345", title: "Some title", url: "some-url" };var post_options = {    //host: 'logger.mysite.co.uk',    host: 'some_url',    path: '/json/name?signature=bd87b1e4b679092a6946de0c6f623567',    port: 80,    timeout: 120000,    method: 'POST',}var sender = http.request(post_options, function(res) {    if (res.statusCode < 399) {        var text = ""        res.on('data', function(chunk) {            text += chunk        })        res.on('end', function(data) {            console.log(text);        })    } else {        console.log("ERROR", res.statusCode)    }});var POST_DATA = 'document='POST_DATA += postDataPOST_DATA += ''sender.write(POST_DATA);sender.end();