首页 新闻 会员 周边

Nodejs post获取数据,WebAPI需要Windows验证

0
悬赏园豆:50 [已关闭问题] 关闭于 2017-02-21 16:21

var express = require('express');
var request = require('request');
var fs = require('fs');
var app = express();

//Lets configure and request
request({
url: 'http://getnt130.mygroup.com/InstantNoodle_SIT/Workbench/api/v1/styleproduct/1/1',
method: 'POST',
// auth: {
// user: 'gfg1\chenwes',
// pass: 'Bot77@'
// },

headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'credentials': {
'userName': 'gfg1\chenwes',
'password': 'Tt556@'
},
},
json: {
"filterType": "LEAF",
"filters": [
{}
],
"attributeName": "item_number",
"searchOperator": "eq",
"filterValue": "15CNLI001CL"
}
}, function (error, response, body) {
if (error) {
console.log(error);
} else {
//console.log(response.statusCode, body);
fs.writeFile("http.log", body, function (err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
}
});
app.listen(3000);

 

在这里,我运行后一直都是401的错误,即没有权限,需要怎样才可以在Post时加入域帐号?

WesChan的主页 WesChan | 初学一级 | 园豆:156
提问于:2017-02-21 09:34
< >
分享
所有回答(1)
0

最终google后,查询到了问题的解决方法,http://stackoverflow.com/questions/33153979/how-to-post-data-using-node-http-ntlm,使用npm包httpntlm解决了问题,具体可以查看文章http://www.cnblogs.com/weschen/p/6424699.html

WesChan | 园豆:156 (初学一级) | 2017-02-21 16:21
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册