2017-04-26 73 views
0

我们正试图通过在门户网站中创建的现有报价的API订购Sydney1 DC中的BareMetal服务器。 我们提取我们在python使用这种方法报价容器:SoftLayer订单从报价失败,错误价格ID 876不存在

container = client['Billing_Order_Quote'].getRecalculatedOrderContainer(id=quote_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有任何修改吗?该报价也是在我们开始接收错误时在同一天创建的新报价。

回答

0

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

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) 

注:与报价

的ID替换quoteId,让我知道,如果这个问题仍然是可重复的。

好吧,我是能够重现该问题,我有一个问题。你是如何创建报价的?你是否使用相同的帐户来创建报价?因为报价由于某种原因导致其报价使用了无效的价格。请检查,当你调用以下方法 价格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. <[email protected]> 
""" 
# 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方法来订购。

问候

+0

尝试都verifyOrder和placeOrder和同时失败与以下错误:'无法订购由于错误:SoftLayerAPIError(SoftLayer_Exception):对象不存在于上执行方法。 (SoftLayer_Billing_Order_Quote :: placeOrder)' – LurgenB

+0

哦,我看到发生了什么是我的错误抱歉,方法需要一个initId参数,它是quoteId我更新了e。g请补充一下,请再试 –

+0

好吧,失败,同样的错误'价格#876不存在' – LurgenB