我打算将下面的curl
API 调用node.js
翻译成虽然我error
在做POST时仍然得到一个。
curl -X POST --user user1@customer1:secret http://demo.test.com/controller/actions/38 -F file=@ExportActions.json
下面是使用 request - npm 模块的初始代码,但 API 调用仍然失败。
var requestdata = fs.readFileSync('./ExportActions.json').toString();
var request = require('request');
request.post({
url: 'https://demo.test.com/controller/actions/38',
auth: {
'user': 'user1@customer1',
'pass': 'secret'
},
body: requestdata
}, function(error, response, body){
console.log(body);
});
每次运行脚本时,我都会收到以下错误:
Could not import Actions: org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
使用模块发布JSON文件时是否有任何解决方法?npm request
谢谢!