Hi there,
I'm a beginner so this problem might be very ease to solve. Nevertheless I posted this question a few days ago and got no helping answer. I hope that someone of you has an idea.
I'm doing a GET request:
to a device that responds with the following raw data:
I had this problem before and could solve it using this method:
Btw. I have to use Python 2.7 due to various reasons...
I think it has to do with a different format of the raw data (a 'list').
I'm searching for a solution for hours now and hope that some of you can help me...
Best,
Leo
I'm a beginner so this problem might be very ease to solve. Nevertheless I posted this question a few days ago and got no helping answer. I hope that someone of you has an idea.
I'm doing a GET request:
requests.get('https://api.xyz.cloud/api/sites/%s?detailed=true' % xyz_site_id, timeout=None, headers=self.headers).json()
to a device that responds with the following raw data:
[{u'address': {u'altitude': None, u'area': u'', u'buildingNumber': None, u'country': None, u'latitude': None, u'longitude': None, u'street': u'', u'zip': u''}, u'id': 63XXXX, u'levelOfAccess': None, u'name': u'Schuppen', u'siteKey': u'YBCL-HXXX'}]I basically want to save the value of
'siteKey'
, meaning YBCL-HXXX
into a variable to use this variable for further actions...I had this problem before and could solve it using this method:
variableX = exampledata['siteKey']Nevertheless, when using this method now I get the following error:
TypeError: list indices must be integers, not str
Btw. I have to use Python 2.7 due to various reasons...
I think it has to do with a different format of the raw data (a 'list').
I'm searching for a solution for hours now and hope that some of you can help me...
Best,
Leo