-->

Softlayer API verify order fail

2019-09-02 14:48发布

问题:

I am trying to order a virtual server in Softlayer using the Softlayer Python client. My order json looks like this:

order = {
'complexType': 'SoftLayer_Container_Product_Order_Virtual_Guest', 
'quantity': 1, 
'virtualGuests': [
      {
        'hostname': 'test', 
        'domain': 'example.com', 
        'primaryBackendNetworkComponent': {
            'networkVlan': {
              'id': 752950
            }
           }
      }
],
'location': 142775, 
'packageId': 46, 
'useHourlyPricing': True,
'prices': [
           {'id': 112863},  # 2 x 2.0 GHz Core
           {'id': 153861},  # 1 GB RAM
           {'id': 23070},  # Reboot / Remote Console
           {'id':  155153},  # 1 Gbps Public & Private Networks
           {'id': 164857},  # 1000 GB Bandwidth
           {'id': 34807},  # 1 IP Address
           {'id': 24013},  # 25 GB (SAN)
           {'id': 23820},  # OS_WINDOWS_2012_FULL_STD_64_BIT
           {'id': 27023},  # Host Ping Monitoring
           {'id': 32500},  # Email and Ticket Notifications
           {'id': 32627},  # Automated Notification Response
           {'id': 33483},  # Unlimited SSL VPN Users & 1 PPTP VPN User per account
           {'id': 36536} # VMWARE VCenter addon
]
}

I verify the order before actually placing it:

client['Product_Order'].verifyOrder(order)

But I keep getting this error message: The price for 2 x 2.0 GHz Cores (#112863) is not valid for location hou02. I have tried all the other locations, but I keep getting the same error message. Do you know I can I resolve this?

回答1:

You need to choose other item price id which is located in the Location/Datacenter that you are using.

To get valid item price ids according to locations, you can execute:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Package/46/getItemPrices?objectMask=mask[id,locationGroupId,item[keyName,description],pricingLocationGroup[locations[id, name, longName]]]

Method: GET

Note: A price id with a locationGroupId = null is considered "A standard price" and the API will internally switch the prices for the customer. But we recommend to execute first the verifyOrder in order to see if the wanted order is ok (the fee can vary).

Additionally, the following request can help you to get valid item prices according to a specific Location/Datacenter (Just adding some filters to the previous request):

  • List of prices with available locations according to a specific package:

    https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Package/[package_id]/getItemPrices?objectMask=mask[id,item.description,hourlyRecurringFee,locationGroupId,pricingLocationGroup[locations[id, name, longName]]]&objectFilter={"itemPrices":{"pricingLocationGroup":{"locations":{"id":{"operation":"814994"}}}}}

Where: "814994" is "Amsterdam 3"

Method: GET

  • Also, to list packages with available locations:

    https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Account/getActivePackages?objectMask=mask[id,name,description,subDescription,locations]