Search code examples
apiibm-cloud-infrastructure

Why do I keep getting a 500 error when I calling the SoftLayer_Billing_Invoice::getItems interface?


Recently I was developing a project that relied on the softlayer interface. I want get the invoice details about the bare metal server. But I keep getting a 500 error when I call the SoftLayer_Billing_Invoice::getItems interface. And other interfaces are normal.

regards~

code show as below:

client = SoftLayer.create_client_from_env(username="username",
                                          api_key="api_key",
                                          proxy="proxy")
sl_billing_invoice = client['Billing_Invoice']
try:
    result = sl_billing_invoice.getItems(id=id)
    print result
except SoftLayer.SoftLayerAPIError as sl_exc:
    msg = 'result:(%s, %s)' % (sl_exc.faultCode, sl_exc.faultString)
    print msg

Return error message as blow:

result:(500, 500 Server Error: Internal Server Error)


Solution

  • The issue is likely that your request is returning a big amount of data, this case commonly happens with invoices and billing items. In order to solve that issue you have the followings options:

    1. Reduce the amount of data through object-masks or using object-filters.

    2. Use pagination (result limits) in order to fetch less data in the request.

      result = sl_billing_invoice.getItems(limit=50, offset=0, id=id)

    Softlayer doc and similar questions:

    https://softlayer.github.io/blog/phil/how-solve-error-fetching-http-headers/

    https://softlayer-python.readthedocs.io/en/latest/api/client.html?highlight=limit#making-api-calls

    Softlayer getAllBillingItems stopped working?

    Getting 500 Internal Server Error from Account.getVirtualGuests()

    getInvoices method failing

    Getting "error": "Internal Error" on Postman and getting error Can not deserialize instance of java.util.ArrayList out of START_OBJECT token