Skip to content Skip to sidebar Skip to footer

Softlayer Getallbillingitems Stopped Working?

The following python script worked like a charm last month: Script: import SoftLayer client = SoftLayer.Client(username='someUser', api_key='someKey') LastInvoice = client['Account

Solution 1:

well the charm has a defect and it is when the response has a big amount of data, that causes timeouts in the response and the conection is closed.

but this issue can be easily solved by using result limits take a look to this example:

import SoftLayer

# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'

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

offset = 0
limit = 50

accountService = client['SoftLayer_Account']

while True:
    try:
        result = accountService.getAllBillingItems(limit=limit, offset=offset)
        offset = offset + limitlimit = limit + limitprint(result)
        if not result:
            break
    except SoftLayer.SoftLayerAPIError as e:
        print("Unable to retrieve the servers . " % (e.faultCode, e.faultString))
        exit(1)

Regards

Post a Comment for "Softlayer Getallbillingitems Stopped Working?"