可能您的帐户有许多计费项目并导致异常,请查看以下文章:
http://sldn.softlayer.com/blog/phil/How-Solve-Error-fetching-http-headers
我可以推荐使用 resultLimits,为了避免异常,看看下面的 Ruby 脚本:
# Get Next Invoice Top Level Billing Items
#
# This script retrieves the billing items that will be on an account's next invoice
#
# Important manual pages:
# http://sldn.softlayer.com/reference/services/SoftLayer_Account/getNextInvoiceTopLevelBillingItems
# http://sldn.softlayer.com/reference/datatypes/SoftLayer_Billing_Item
#
# @license <http://sldn.softlayer.com/article/License>
# @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
require 'rubygems'
require 'softlayer_api'
require 'pp'
# Helper function to fetch through all results from SoftLayer api
# using small page sizes and sleeping before every new page fetch.
def fetch_all(service, method)
records = []; offset = 0; limit = 1000
loop do
results = service.result_limit(offset, limit).send(method)
records += results
break if results.size < limit
offset += limit
sleep 3
end
records
end
# Creating the account service.
billing = SoftLayer::Service.new("SoftLayer_Account", :username => "set me", :api_key => "set me", :timeout => 200)
# object mask
object_mask = "mask[orderItem[order[userRecord[username]]], invoiceItem[totalRecurringAmount]]"
begin
# Calling helper function to get all the result for getNextInvoiceTopLevelBillingItems method
user_bill = fetch_all(billing.object_mask(object_mask), :getNextInvoiceTopLevelBillingItems)
# Print
pp user_bill
rescue StandardError => exception
puts "Error: #{exception}"
end
我希望它有帮助