如果我不传递userData节,则JSON有效负载基本上可以创建VSI。
我收到RCV 400 MSG“错误请求”,错误为“ {“错误”:“错误请求”,“代码”:“ SoftLayer_Exception_WebService_BadRequest”}'
使用POS方法的URL为https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest
JSON有效负载为:
{ “参数”: [ {“主机名”:“ garycs-test-userdata-02”, “ domain”:“ sl.cloud9.ibm.com”, “ startCpus”:2 “ maxMemory”:2 “ hourlyBillingFlag”:“ true”, “ operatingSystemReferenceCode”:“ CENTOS_7_64”,
"localDiskFlag" : false,
"userData" : [
{
"value" : "{"dataclass":"IBMConfidential"}",
"type: : {
"name" : "User Data",
"keyname" : "USER_DATA"
}
}
],
"networkComponents" : [
{
"maxSpeed" : 1000
}
],
"privateNetworkOnlyFlag" : true,
"primaryBackendNetworkComponent" : {
"networkVlan" : {
"id": 2298951
}
},
"datacenter" : {
"name" : "dal13"
}
}
]
}
userData节有什么问题?
答案 0 :(得分:0)
失败的原因是“ value”属性需要包含一个字符串值,因为当您发送多个双引号时,json结构被破坏,并且当您发送该字符串时,由于这个原因会引发异常消息错误请求
我建议尝试使用简单的引号或换号将双引号替换为字符串值,例如以下示例:
"userData": [
{
"value": "{'dataclass':'IBMConfidential'}",
"type": {
"name": "User Data",
"keyname": "USER_DATA"
}
}
],
或者:
"userData": [
{
"value": "{\"dataclass\":\"IBMConfidential\"}",
"type": {
"name": "User Data",
"keyname": "USER_DATA"
}
}
],
有关更多参考,请参见以下内容:
https://softlayer.github.io/reference/services/SoftLayer_Virtual_Guest/createObject/
https://softlayer.github.io/reference/services/SoftLayer_Resource_Metadata/getUserMetadata/