Skip to content

Instantly share code, notes, and snippets.

@chechedotmx
Last active December 18, 2015 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chechedotmx/5696213 to your computer and use it in GitHub Desktop.
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
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