【发布时间】:2017-03-07 22:17:50
【问题描述】:
我正在尝试使用 REST API 上传文件。我有一个适用于所有其他类型请求的函数,但是这个(上传文件)不想工作:
var createItem = function ()
{
request.post(
{
url:browser.params.baseRestUrl + 'repositories/Samples/items',
auth: browser.params.auth,
body: fs.createReadStream(filepath),
form:
{
headers: {'content-type': 'application/octet-stream',
'Content-Disposition': 'attachment; filename="oneHourSally3.fmw"',
'Accept': 'application/json'
},
}
},
function(e,r,user){ console.log("Status code of createItem('oneHourSally'): " + r.statusCode);});
};
这会返回一个 http 415(不支持的媒体类型)错误。
【问题讨论】:
标签: javascript node.js rest