Last active
December 18, 2015 00:19
-
-
Save chechedotmx/5696213 to your computer and use it in GitHub Desktop.
Simple way to request blitline from azure mobile services or nodejs, without getting 411 errors, and string not matched
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = function() { | |
return { | |
sendHttpPostToBlitline : function(job_data, callBackBitline) { | |
var http = require('http'); | |
var json_job_data = new Object(); | |
json_job_data.json = job_data; | |
var job_data_stringified = JSON.stringify(json_job_data); | |
var options = { | |
host : 'api.blitline.com', | |
port : 80, | |
method : "POST", | |
path : '/job', | |
headers : { | |
'Content-Type' : 'application/json', | |
'Content-Length' : job_data_stringified.length | |
} | |
}; | |
console.log("Submitting to Blitline size(" + job_data_stringified.length + ") Job Data :" + job_data_stringified); | |
var req = http.request(options, callBackBitline); | |
req.write(job_data_stringified); | |
req.end(); | |
} | |
} | |
}(); | |
//Using this | |
foo.sendHttpPostToBlitline(job_data,callBackBitline); | |
//Where job_data is the blitline request javascript object and callbackblitline is the return function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment