【问题标题】:SoftLayer order from quote fails with error Price ID 876 does not exist来自报价的 SoftLayer 订单失败,并出现错误价格 ID 876 不存在
【发布时间】:2017-04-27 22:39:36
【问题描述】:

我们正在尝试通过 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 是否有任何更改?该报价也是在我们开始收到错误的同一天创建的新报价。

【问题讨论】:

    标签: ibm-cloud-infrastructure


    【解决方案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 方法来订购。

    问候

    【讨论】:

    • 尝试了 verifyOrder 和 placeOrder 都失败并出现以下错误:Failed to order due to error: SoftLayerAPIError(SoftLayer_Exception): Object does not exist to execute method on. (SoftLayer_Billing_Order_Quote::placeOrder)
    • 哦,我知道发生了什么,这是我的错误,抱歉,这些方法需要一个 init 参数,即我更新的 quoteId,例如添加请再试一次
    • 好的,失败并出现同样的错误Price # 876 does not exist
    • 你能给我报价的ID吗?似乎是这个 "2135231" ,但我不太确定。
    • 是的,我使用同一个帐户创建了报价单。然而,话虽如此,我确实注意到了一个将多个帐户链接到 IBMid 的错误。如果我登录到一个帐户然后切换到另一个帐户并提供报价,那么报价会包含第一个帐户的详细信息?但是,我确认此报价显示在我在脚本中使用的相同帐户 API 凭据的报价列表中。今天还注意到我无法使用 IBMid 在门户中切换帐户。您知道今天的 IBMid 是否存在问题?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    • 1970-01-01
    相关资源
    最近更新 更多