软层客户端:无法通过 REST API 为 User_Customer 更新 VPN
softlayer-client: unable to update VPN for User_Customer via REST API
我正在对特定用户试验 softlayer-client api wrapper in my Node Express application. My goal is to update the VPN password of a User_Customer by calling the updateVpnPassword 方法。
我可以使用 request
构造调用来实现 VPN 密码更新,但我不确定这是达到预期结果的最佳方法。
可以使用softlayer-client模块来做类似的调用吗:
function updateVpnPassword(req, res, next) {
// Construct URL to update VPN
myURL = 'https://' + <userIDAdmin> + ':' + <apiKeyAdmin> + '@api.softlayer.com/rest/v3/SoftLayer_User_Customer/' + <softLayerID> + '/updateVpnPassword/' + <newPassword> + '.json';
request.get({url: myURL}, function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body);
});
next();
}
我最初的尝试是尝试对此进行变体:
function updateVpnPassword(req, res, next) {
// Assuming var client = new SoftLayer();
client
.auth(<userIDAdmin>, <apiKeyAdmin>)
.path('User_Customer', <softLayerID>,'updateVpnPassword')
.parameters(<newPassword>)
.put(function(err,result){
console.log(result);
if (err) {
next(err); // Pass errors to Express.
}
else {
// update successful
}
});
next();
}
但控制台日志给出错误响应,如
{ message: { error: 'Internal Error', code: 'SoftLayer_Exception_Public' } }
。
我希望得到 TRUE 或 FALSE 响应,以指示更新是否成功。
可以找到类似的 python 客户端 但我需要在 JS 中实现。
我不熟悉 nodejs 但我安装了包 softlayer-node 和 运行 你的第二个代码并且它有效。
我还创建了以下脚本并且得到了 TRUE
var username = 'set me';
var apikey = 'set me';
var userId = 1111111;
var SoftLayer = require('softlayer-node');
var client = new SoftLayer();
client
.auth(username, apikey)
.path('User_Custome', userId, 'updateVpnPassword')
.parameters('P@ssword123')
.put()
.then(function(result) {
console.log(result);
}, function(error) {
console.log(error);
});
节点命令:
$ node updateVpnPassword.js
true
您是否尝试过使用 curl 或邮递员等任何其他 REST 客户端发送该请求?
如果您遇到同样的错误,那么我建议您提交一个票证并提供信息,例如您尝试更新 vpn 密码的用户 ID 以及您向其发送请求的用户。
我正在对特定用户试验 softlayer-client api wrapper in my Node Express application. My goal is to update the VPN password of a User_Customer by calling the updateVpnPassword 方法。
我可以使用 request
构造调用来实现 VPN 密码更新,但我不确定这是达到预期结果的最佳方法。
可以使用softlayer-client模块来做类似的调用吗:
function updateVpnPassword(req, res, next) {
// Construct URL to update VPN
myURL = 'https://' + <userIDAdmin> + ':' + <apiKeyAdmin> + '@api.softlayer.com/rest/v3/SoftLayer_User_Customer/' + <softLayerID> + '/updateVpnPassword/' + <newPassword> + '.json';
request.get({url: myURL}, function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body);
});
next();
}
我最初的尝试是尝试对此进行变体:
function updateVpnPassword(req, res, next) {
// Assuming var client = new SoftLayer();
client
.auth(<userIDAdmin>, <apiKeyAdmin>)
.path('User_Customer', <softLayerID>,'updateVpnPassword')
.parameters(<newPassword>)
.put(function(err,result){
console.log(result);
if (err) {
next(err); // Pass errors to Express.
}
else {
// update successful
}
});
next();
}
但控制台日志给出错误响应,如
{ message: { error: 'Internal Error', code: 'SoftLayer_Exception_Public' } }
。
我希望得到 TRUE 或 FALSE 响应,以指示更新是否成功。
可以找到类似的 python 客户端
我不熟悉 nodejs 但我安装了包 softlayer-node 和 运行 你的第二个代码并且它有效。
我还创建了以下脚本并且得到了 TRUE
var username = 'set me';
var apikey = 'set me';
var userId = 1111111;
var SoftLayer = require('softlayer-node');
var client = new SoftLayer();
client
.auth(username, apikey)
.path('User_Custome', userId, 'updateVpnPassword')
.parameters('P@ssword123')
.put()
.then(function(result) {
console.log(result);
}, function(error) {
console.log(error);
});
节点命令:
$ node updateVpnPassword.js
true
您是否尝试过使用 curl 或邮递员等任何其他 REST 客户端发送该请求?
如果您遇到同样的错误,那么我建议您提交一个票证并提供信息,例如您尝试更新 vpn 密码的用户 ID 以及您向其发送请求的用户。