上記の注文情報を送信するには、注文時に「itemCategoryQuestionAnswers」パラメータを入力する必要があります。このパラメータは、Container_Product_Order_Virtual_GuestやContainer_Product_Order_Hardware_Serverなどのデータタイプにあります。
以下は、REST の JSON の例です。
"itemCategoryQuestionAnswers":[
{
"answer": "2",
"categoryId": 14,
"questionId": 14
},
{
"answer": "4",
"categoryId": 14,
"questionId": 15
}
]
The example above belongs to the first two questions in the form. As you can see, it is necessary to know the id of categoryId and questionId parameters. Follow the steps below.
CategoryID
As greyhoundforty comment you, the link SoftLayer API: Ordering Subnet is a good starting point. On that page mcruz shows how to execute the method Product_Item_Category::getSubnetCategories. The method returns some thing like this:
{
"categoryCode": "global_ipv6",
"id": 331,
"name": "Global IPv6",
"quantityLimit": 0
},
{
"categoryCode": "sec_ip_addresses",
"id": 14,
"name": "Public Secondary IP Addresses",
"quantityLimit": 0
},
On this case the categoryId is 14 for category "Public Secondary IP Addresses".
QuestionID
To get all questions related to the category "sec_ip_addresses" you can use the method Product_Item_Category::getQuestions or Product_Item_Category::getQuestionReferences. On this case I'll show you how execute getQuestionReferences method:
https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Item_Category/14/getQuestionReferences?objectMask=[question]
Method: GET
It should returns something like this:
{
"id": 61,
"questionId": 14,
"required": true,
"question": {
"description": "The number of IP addresses expected to be used within the next 30 days.",
"id": 14
}
},
{
"id": 62,
"questionId": 15,
"required": true,
"question": {
"description": "The number of IP addresses expected to be used within the next 12 months.",
"id": 15
}
},
Now you can know the questionId of each question in the form.
Order Virtual Guest with a Secondary Public Ip Address
Below is an example in REST to order a virtual guest with a secondary ip address and two first questions in the form.
Note: Don't forget change [username], [apikey], prices, and other ids with your own data
https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder
Method: POST
Body JSON:
{
"parameters":[
{
"complexType": "SoftLayer_Container_Product_Order_Virtual_Guest",
"packageId": 46,
"location": "AMSTERDAM",
"quantity": 1,
"prices":[
{"id":14640},
{"id":11644},
{"id":9205},
{"id":22272},
{"id":52231},
{"id":21},
{"id":2202},
{"id":13945},
{"id":55},
{"id":57},
{"id":58},
{"id":420},
{"id":418},
{"id":22}
],
"virtualGuests":[
{
"hostname": "test",
"domain": "example.com"
}
],
"itemCategoryQuestionAnswers":[
{
"answer": "2",
"categoryId": 14,
"questionId": 14
},
{
"answer": "4",
"categoryId": 14,
"questionId": 15
}
]
}
]
}
I don't know what REST client you are using, but I was able to reproduce your issue in a RESTclient from firefox, in other REST clients like Insomnia I'm just getting errors.
Basically, you are getting empty response because your JSON structure have some mistakes. First, all data in body needs to be into "parameters" object, please review the example above. Second, value of "sshKeyIds" needs to be into double quotes because it is an string. Finally, I recommend you put all objects and string values into double quotation mark due to it is the JSON standard format, you can verify this information in jQuery.parseJSON single quote vs double quote and http://www.json.org/.
重要: placeOrder メソッドを使用する前に、最初に verifyOrderを実行することをお勧めします。注文する準備ができたら、URL リクエストの verifyOrder を placeOrder に変更するだけです。
リクエストを次のように変更しました
https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder
Method: POST
Body in JSON format:
{
"parameters":[
{
"complexType" : "SoftLayer_Container_Product_Order_Virtual_Guest",
"location" : "449604",
"packageId" : 46,
"quantity" : 1,
"useHourlyPricing" : true,
"virtualGuests" : [
{
"domain" : "aaa.com",
"hostname" : "sshkey_07"
}
],
"sshKeys" : [
{ "sshKeyIds" : ["620913L"] }
],
"prices" : [
{"id" : 1644 },
{"id" : 2202 },
{"id" : 2259 },
{"id" : 273 },
{"id" : 1640 },
{"id" : 17442},
{"id" : 905 },
{"id" : 21 },
{"id" : 57 },
{"id" : 55 },
{"id" : 58 },
{"id" : 420 },
{"id" : 418 },
{"id" : 22 },
{"id" : 1800 }
],
"itemCategoryQuestionAnswers" : [{
"answer" : "4",
"questionId" : 14,
"categoryCode" : "sec_ip_addresses",
"categoryId" : 14
}, {
"answer" : "4",
"questionId" : 15,
"categoryCode" : "sec_ip_addresses",
"categoryId" : 14
}, {
"answer" : "aaaa",
"questionId" : 16,
"categoryCode" : "sec_ip_addresses",
"categoryId" : 14
}, {
"answer" : "allesa",
"questionId" : 9,
"categoryCode" : "sec_ip_addresses",
"categoryId" : 14
}, {
"answer" : "product manager",
"questionId" : 10,
"categoryCode" : "sec_ip_addresses",
"categoryId" : 14
}, {
"answer" : "[email protected]",
"questionId" : 11,
"categoryCode" : "sec_ip_addresses",
"categoryId" : 14
}, {
"answer" : "xxxxxxxxx",
"questionId" : 12,
"categoryCode" : "sec_ip_addresses",
"categoryId" : 14
}, {
"answer" : "1",
"questionId" : 13,
"categoryCode" : "sec_ip_addresses",
"categoryId" : 14
}
]
}
]
}
ご不明な点がある場合や、さらにサポートが必要な場合はお知らせください。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加