我有以下代码使用API和nodejs在softlayer中添加批量硬件访问:
slClient
.auth(slUserID, slApiKey)
.path('User_Customer', userID, 'addBulkHardwareAccess',{"hardwareIds":["XXXXX,XXXXXXX"]})
.post()
.then(res => {
resolve(res);
})
.catch(err => {
reject(err);
});
};
但是它给出了错误: TypeError:无法读取未定义的属性“构造函数”
答案 0 :(得分:1)
要添加批量硬件访问,请使用以下rest api:
方法:开机自检
https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_User_Customer/[userCustomerId]/addBulkHardwareAccess
身体:杰森
{
"parameters":[
[
111111,
222222,
333333,
444444
]
]
}
参考:
https://softlayer.github.io/reference/services/SoftLayer_User_Customer/addBulkHardwareAccess/
或者,如果您想添加对所有硬件的访问权限,请使用此rest api:
方法:开机自检
https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_User_Customer/[userCustomerId]/addPortalPermission
身体:杰森
{
"parameters": [
{
"keyName": "ACCESS_ALL_HARDWARE"
}
]
}
参考:
https://softlayer.github.io/reference/services/SoftLayer_User_Customer/addPortalPermission/
答案 1 :(得分:0)
有parameters()方法可以提供参数。
slClient
.auth(slUserID, slApiKey)
.path('User_Customer', args.userID, 'addBulkHardwareAccess')
.parameters([[XXXXXX,XXXXXXXXXX]])
.post()
.then(res => {
resolve(res);
})
.catch(err => {
reject(err);
});