我正在尝试使用 node-libcurl向checkr api发出 POST 请求。我需要创建并向候选人发送背景调查邀请,但我Bad authentication error
从他们的 api 中得到了回复。有什么帮助吗?
服务器.js
const data = {
'candidate_id': 'someid',
'package': 'driver_pro',
};
var checkr_sk = 'my_secret_key';
const Curl = require( 'node-libcurl' ).Curl;
curl = new Curl();
curl.setOpt(Curl.option.URL, `https://api.checkr.com/v1/invitations/${checkr_sk}`);
curl.setOpt('FOLLOWLOCATION', true);
curl.setOpt(Curl.option.POST, true);
curl.setOpt(Curl.option.HTTPHEADER, ['Content-Type: application/json']);
curl.setOpt(Curl.option.POSTFIELDS, JSON.stringify(data));
curl.on('end', function (statusCode, body, headers) {
var result = JSON.parse(body);
console.info(statusCode);
console.info(headers);
console.info(body);
console.info(this.getInfo(Curl.info.TOTAL_TIME));
this.close();
});
curl.on('error', function (err, curlErrorCode) {
console.error(err);
console.error(curlErrorCode);
this.close();
});
curl.perform();