Skip to content

Instantly share code, notes, and snippets.

@AlekseyA
Created June 3, 2020 13:36
Show Gist options
  • Select an option

  • Save AlekseyA/87f9f80ae281202036b584ed9dbf688f to your computer and use it in GitHub Desktop.

Select an option

Save AlekseyA/87f9f80ae281202036b584ed9dbf688f to your computer and use it in GitHub Desktop.
Working with Rchili API
const path = require('path')
const axios = require('axios');
const fs = require('fs'),
// file data from file
FILE_DATA=base64_encode(path.resolve('..', 'CV 6.pdf'));
/**
* HOW TO Make an HTTP Call - POST
*/
// do a POST request
// create the JSON object
function base64_encode(file) {
// read binary data
var binaryData = fs.readFileSync(file);
// convert binary data to base64 encoded string
return new Buffer(binaryData).toString('base64');
}
jsonObject = JSON.stringify({
// 'filedata':FILE_DATA,
// //filename
// 'filename':'CV 6.pdf'
"url" : "https://jenna-candidates-cvs.s3.us-east-2.amazonaws.com/1588780101382.pdf",
'userkey':'key',
'version':'8.0.0',
'subuserid':'id'
});
// prepare the header
var postheaders = {
'Content-Type' : 'application/json',
'Content-Length' : Buffer.byteLength(jsonObject, 'utf8')
};
axios({
method: 'post',
url: 'https://rest.rchilli.com/RChilliParser/Rchilli/parseResume',
// url: 'https://rest.rchilli.com/RChilliParser/Rchilli/parseResumeBinary', // for binary files
data: jsonObject,
headers: postheaders
}).then(res => {
console.log('res is', res);
}).catch(err => {
console.log('err >>', err);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment