这是server.js中的代码
const https = require('https')
const http = require("http");
const fs = require('fs');
const fileUrl = new URL('file:///Users/someone.computer/Desktop/sampleFile.csv');
const post_data = fs.readFileSync(fileUrl);
const options = {
host: 'api.thomsonreuters.com',
// port: 443,
path: '/permid/match/file',
method: 'POST',
headers: {
'x-ag-access-token': 'myToken',
'x-openmatch-numberOfMatchesPerRecord': 1,
'x-openmatch-dataType': 'Organization',
'Content-Type': 'multipart/form-data'
}
}
const req = https.request(options, (res) => {
var str = '';
console.log(res)
console.log(`statusCode: ${res.statusCode}`)
res.on('data', function (chunk) {
str += chunk;
console.log("this is chunk = " + chunk)
});
res.on("end", function () {
console.log("this is str = " + str)
})
})
req.write(post_data);
req.end();
我需要使用csv文件并通过permid.org运行它,并使用其API文件匹配功能匹配包含要匹配数据的本地csv文件。在他们的docs中,它说我需要包括参数和标头,就像我在下面称为options
的对象中包含的一样。要读取我正在使用的文件fs npm package
当我运行node server.js
时,我进入终端机
statusCode: 500
this is chunk = {"error": {"status": {
"code": "500",
"errorCode": "Server Error",
"errorDescription": "java.lang.NullPointerException"
}}}
this is str = {"error": {"status": {
"code": "500",
"errorCode": "Server Error",
"errorDescription": "java.lang.NullPointerException"
}}}
请告知我我在做什么错-预先感谢!