问题描述
我正在尝试下订单,但出现了一些错误 休息 API:https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Order/placeOrder
BODY: { "parameters": [ { "complexType": "SoftLayer_Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace","packageId": 240,"prices": [ { "id": 201527 } ],"volumeId": 200326976 }] } >
响应:{"error":"20 GB 存储空间的价格 (#201527) 对位置 ams01 无效。","code":"SoftLayer_Exception_Public"}
解决方法
尝试使用这个身体
{
"parameters":[
{
"complexType":"SoftLayer_Container_Product_Order_Network_Storage_Enterprise","location":"AMSTERDAM","quantity":1,"packageId":240,"prices":[
{"id": 45098},# Block Storage keyName: storage_block
{"id": 45058},# Endurance Storage keyName: storage_service_enterprise
{"id": 45138},# 20 GB Storage Space keyName: performance_storage_space
{"id": 45088},# 4 IOPS per GB keyName: storage_tier_level
{"id": 46140} # 5 GB Storage Space keyName: storage_snapshot_space
],"osFormatType":{
"keyName":"LINUX"
}
}
]
}
参考资料
https://sldn.softlayer.com/python/order_endurance_storage/ https://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Network_Storage_Object/ https://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getAllObjects/ https://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getItemPrices/
,像特定价格对位置无效的错误,通常意味着该商品价格对特定位置无效,因此为了修复您的订单,您可以尝试使用标准价格,该价格可以与订购时的任何位置。
在 SoftLayer_Product_Item_Price 数据类型中,如果“locationGroupId”为空,则价格被视为标准价格。 另一方面,您使用的是 201527 价格 ID,其中项目“keyName”是“20_GB_PERFORMANCE_STORAGE_SPACE”,然后知道这些值您可以构建一个对象 filter 如下:
objectFilter={
"itemPrices": {
"locationGroupId": {
"operation": "is null"
},"item": {
"keyName": {
"operation": "20_GB_PERFORMANCE_STORAGE_SPACE"
}
}
}
}
并且您可以使用以下 API 调用来检索所有标准价格:
https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/240/getItemPrices?objectFilter={"itemPrices":{"locationGroupId":{"operation":"is null"},"item":{"keyName": { "operation" : "20_GB_PERFORMANCE_STORAGE_SPACE"}}}}&objectMask=mask[id,item[keyName,description],locationGroupId]
响应示例:
[
{
"id": 46659,"locationGroupId": null,"item": {
"description": "20 GB Storage Space","keyName": "20_GB_PERFORMANCE_STORAGE_SPACE"
}
},{
"id": 45128,
例如,尝试在您的 JSON 正文中使用上面检索到的标准价格,您也可以使用 verify 方法进行检查:
发布:
https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Order/verifyOrder
身体:
{
"parameters": [
{
"complexType": "SoftLayer_Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace","packageId": 240,"prices": [
{
"id": 45128
}
],"quantity": 1,"location": "AMSTERDAM","volumeId": 200326976
}
]
}