Skip to content

Instantly share code, notes, and snippets.

@illbzo1
Last active August 29, 2015 14:22
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 illbzo1/e75c503f5e0c3a9fc5ab to your computer and use it in GitHub Desktop.
Save illbzo1/e75c503f5e0c3a9fc5ab to your computer and use it in GitHub Desktop.
An example for making POST requests to DocRaptor in Node.js, using request instead of restler
var request = require('request');
var fs = require('fs');
var content = "<html><body>TEST!</body></html>";
config = {
url: 'https://docraptor.com/docs',
encoding: null, //IMPORTANT! This produces a binary body response instead of text
headers: {
'Content-Type': 'application/json'
},
json: {
user_credentials: "YOUR_API_KEY_HERE",
doc: {
document_content: content,
name: "test.pdf",
document_type: "pdf",
test: true
}
}
};
request.post(config, function(err, response, body) {
fs.writeFile('doc_raptor_sample.pdf', body, "binary", function(writeErr) {
console.log('Saved!');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment