Softlayer getAllBillingItems stopped working?

2024/10/15 3:20:17

The following python script worked like a charm last month:

Script:

import SoftLayer
client = SoftLayer.Client(username='someUser', api_key='someKey')
LastInvoice = client['Account'].getAllBillingItems()
print LastInvoice

Today's result:

C:\Python27\python.exe C:/Users/username/Documents/Python/Softlayer/Softlayer5.py
Traceback (most recent call last):File "C:/Users/username/Documents/Python/Softlayer/Softlayer5.py", line 8, in <module>LastInvoice = client['Account'].getAllBillingItems()File "C:\Python27\lib\site-packages\SoftLayer\API.py", line 392, in call_handlerreturn self(name, *args, **kwargs)File "C:\Python27\lib\site-packages\SoftLayer\API.py", line 360, in callreturn self.client.call(self.name, name, *args, **kwargs)File "C:\Python27\lib\site-packages\SoftLayer\API.py", line 263, in callreturn self.transport(request)File "C:\Python27\lib\site-packages\SoftLayer\transports.py", line 197, in __call__raise exceptions.TransportError(ex.response.status_code, str(ex))
SoftLayer.exceptions.TransportError: TransportError(500): 500 Server Error: Internal Server Error for url: https://api.softlayer.com/xmlrpc/v3.1/SoftLayer_Account

Other api actions work fine... any thoughts?

Answer

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 = 50accountService = client['SoftLayer_Account']while True:try:result = accountService.getAllBillingItems(limit=limit, offset=offset)offset = offset + limitlimit = limit + limitprint(result)if not result:breakexcept SoftLayer.SoftLayerAPIError as e:print("Unable to retrieve the servers . " % (e.faultCode, e.faultString))exit(1)

Regards

https://en.xdnf.cn/q/117878.html

Related Q&A

Looking for a specific value in JSON file

I have a json file created by a function. The file is looks like this :{"images": [{"image": "/WATSON/VISUAL-REC/../IMAGES/OBAMA.jpg", "classifiers": [{"cla…

How to put many numpy files in one big numpy file without having memory error?

I follow this question Append multiple numpy files to one big numpy file in python in order to put many numpy files in one big file, the result is: import matplotlib.pyplot as plt import numpy as np i…

scraping : nested url data scraping

I have a website name https://www.grohe.com/in In that page i want to get one type of bathroom faucets https://www.grohe.com/in/25796/bathroom/bathroom-faucets/grandera/ In that page there are multiple…

How to trigger an action once on overscroll in Kivy?

I have a ScrollView thats supposed to have an update feature when you overscroll to the top (like in many apps). Ive found a way to trigger it when the overscroll exceeds a certain threshold, but it tr…

Python - Print Each Sentence On New Line

Per the subject, Im trying to print each sentence in a string on a new line. With the current code and output shown below, whats the syntax to return "Correct Output" shown below?Codesentenc…

pyinstaller struct.error: unpack requires a bytes object of length 16 [closed]

Closed. This question needs debugging details. It is not currently accepting answers.Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to repro…

Getting the quarter where recession start and recession ends along with the quarter of minimum gdp

Quarter: GDP: GDP change: change 1999q3 9 -- ------ 1999q4 10 1 increase 2000q1 9 -1 decline 2000q2 8 -1 de…

Inherit view and adding fields

I want to add my 2 fields boatlenght and fuelcapacity under price list in product form view but they are not showing up. What did i miss.<?xml version="1.0" encoding="utf-8"?&g…

Linux and python: Combining multiple wave files to one wave file

I am looking for a way that I can combine multiple wave files into one wave file using python and run it on linux. I dont want to use any add on other than the default shell command line and default py…

How does the in operator determine membership? [duplicate]

This question already has answers here:Set "in" operator: uses equality or identity?(5 answers)Closed 7 years ago.How does the in operator work for Python? In the example below I have two n…