Search code examples
ibm-cloud-infrastructure

Is there any way to get the output of a softlaye API sorted by one of the attribute?


I am using an API to list invoices of typeCode=RECURRING.

I noticed that I get the output with the oldest invoice(oldest createDate) at the top. Can I have the output in reverse order i.e. the invoice with the latest createDate on the top?

Thanks.


Solution

  • try this:

    GET https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getInvoices?objectFilter={"invoices": {"typeCode": {"operation": "RECURRING"}, "createDate": {"operation": "orderBy", "options": [{"name": "sort", "value": ["ASC"]}, {"name": "lower"}, {"name": "sortOrder", "value":[1]}]}}}
    

    change "ASC" by "DESC" if you need the output in reverse order

    Regards