来自报价的SoftLayer订单失败,错误,价格ID 876不存在

时间:2017-04-26 03:06:22

标签: ibm-cloud-infrastructure

我们正尝试通过API从门户网站中创建的现有报价中订购Sydney1 DC中的BareMetal服务器。 我们在python中使用这个方法提取我们的引用容器:

    container = client['Billing_Order_Quote'].getRecalculatedOrderContainer(id=quote_id)

我们不会对容器中的价格ID进行任何更改。当我们尝试使用以下方式验证订单或下订单时:

    result = client['Product_Order'].verifyOrder(container)

失败并出现以下错误:

    Failed to order due to error: SoftLayerAPIError(SoftLayer_Exception_Public): Price # 876 does not exist.

这是显示ID 876的容器的JSON摘录:

 "currentPriceFlag": "",
  "hourlyRecurringFee": "0",
  "id": 876,
  "item": {
    "activePresaleEvents": [],
    "attributes": [],
    "availabilityAttributes": [],
    "bundle": [],
    "description": "Non-RAID",
    "id": 487,
    "itemCategory": {
      "categoryCode": "disk_controller",
      "id": 11,
      "name": "Disk Controller",
      "quantityLimit": 0,
      "questions": []
    },
    "itemTaxCategoryId": 166,
    "keyName": "DISK_CONTROLLER_NONRAID",
    "softwareDescriptionId": "",
    "thirdPartyPolicyAssignments": [],
    "upgradeItemId": ""
  },

尝试过使用不同硬件的不同引号。如果我们通过门户网站使用相同的报价进行订购,那么只有API在使用Non-Raid时遇到问题?同样的脚本也在一周前工作,那么对Product_Order API进行了哪些更改?引用也是在我们开始收到错误的同一天创建的新引号。

1 个答案:

答案 0 :(得分:1)

我所知道的控制门户使用这些方法来引用:

http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Order_Quote/verifyOrder http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Order_Quote/placeOrder

因此,尝试使用这些方法修改代码,例如

result = client['Billing_Order_Quote'].verifyOrder(container,id=quoteId)

注意:将quoteId替换为引用的ID

如果问题仍然可以重现,请告诉我。

我能够重现这个问题,我有一个问题。你是怎么创造报价的?你是否使用同一帐户来创建报价?由于某些原因导致您的帐户使用无效价格,因此报价出现问题。请检查一下 当您调用以下方法时,会列出价格876:

result = client['SoftLayer_Product_Package'].getItemPrices(id=packageID)
Note: replace the packageID with the package that your quote is using, it seems is 253

如果您看不到列出的价格876,那就是问题,而且与报价的错误创建有关。

您可以更改有效价格,以避免错误,例如

"""
Order from account's quote.
This script creates an order from a account's quote presented
in the SoftLayer Customer Portal's (https://control.softlayer.com/account/quotes)

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getQuotes
http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Order_Quote/getRecalculatedOrderContainer
http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Order_Quote/placeOrder
@License: http://sldn.softlayer.com/article/License
@Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
# So we can talk to the SoftLayer API:
import SoftLayer

# For nice debug output:
import pprint
"""
Your SoftLayer API username and key.
Generate an API key at the SoftLayer Customer Portal
"""
API_USERNAME = 'set me'
API_KEY = 'set me'

client = SoftLayer.Client(username=API_USERNAME, api_key=API_KEY)

"""
Set the id of the quote from which you want to create the order,
use SoftLayer_Account::getQuotes method to get a list of quotes from account
"""
quoteId = 2135231
# Get the order data by using SoftLayer_Billing_Order_Quote::getRecalculatedOrderContainer method
orderTemplates = client['SoftLayer_Billing_Order_Quote'].getRecalculatedOrderContainer(id=quoteId)
# Changing the wrong price for a valid one
prices = []
for price in orderTemplates["prices"]:
    if price["id"] != 876:
        prices.append(price)

prices.append({"id": 141949})
orderTemplates["prices"] = prices

try:
    """
    Verify the order container is right. If this returns an error
    then fix your order container and re-submit. Once ready then place
    your order with the placeOrder() method.
    """
    receipt = client['SoftLayer_Billing_Order_Quote'].verifyOrder(orderTemplates, id=quoteId)
    pprint.pprint(receipt)
except SoftLayer.SoftLayerAPIError as e:
    print("error faultCode=%s, faultString=%s"
          % (e.faultCode, e.faultString))
    exit(1)

在某种程度上,控制门户必须在执行订单之前更改无效价格,这就是它在门户网站中工作的原因,因为正如我之前告诉您的那样,两者都使用相同的API方法进行订购。

此致