1

How can I reference a specific attribute/row in the results returned by client.service? I'd like to return just the value of the 'OverallStatus' shown below. Here is my code snippet:

from zeep import Client
url='https://someframework.wsdl'
client = Client(wsdl=url)
results = client.service.GetSystemStatus

Here is the 'results()' type:

print(type(results()))    
<class 'zeep.objects.SystemStatusResponseMsg'>

And here is what's contained in 'results()':

print(results())
{
        'Result': [
                'StatusCode': 'OK',
                'StatusMessage': 'System Status Retrieved',
                'SystemStatus': 'OK',
                'Outages': None
            }
        ]
    },
    'OverallStatus': 'OK'
}

I'd like to call something like:

print(results['OverallStatus'])

or

print(results['SystemStatus'])

and just see it's value of 'OK' printed on screen. I'm a bit of a Python newbie, have reviewed casting the object into dicts, lists, tuples, etc. but feel like I'm missing something and have started going into circles.

heyjon
  • 73
  • 1
  • 7
  • I was able to figure out how to reference the 'OverAllStatus' attribute with `print(results().OverallStatus)` however I'm still stuck on referencing the items inside the 'Result' object. – heyjon Aug 10 '21 at 19:59

1 Answers1

1

Found this SO answer that helped point me in the right direction: Python Accessing Nested JSON Data

Without needing to any manipulation this snippet was able to get me the output I was seeking:

>>> print(results()['Result'][0]['SystemStatus']) 
OK
heyjon
  • 73
  • 1
  • 7