0
我正嘗試使用REST API上傳文件。我有每一個其他類型的請求工作的功能,但是這一次(這上傳文件)不想工作:通過REST API上傳文件的'fs'和'request'節點
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(不支持的媒體類型)錯誤。