2017-04-26 70 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