Oct-24-2019, 05:31 PM
Hi,
I am very new to Python and I apologise if I am asking this wrong. I have retrieved a list of tenants via the API I am trying to use. I need to retrieve the ID, Name and Region from the result. I have 10 tenants.
I managed to do this earlier in my code, but that didn't returned any items, just a set of tokens that were easy to retrieve. How do I get just the tokens I want from this list? Below is my code
<class 'dict'>: {'items': [{'id': '0e717975-4dce-b911-23276700d154', 'name': 'UK', 'dataGeography': 'IE', 'dataRegion': '01', 'billingType': 'trial', 'partner': {'id': '31e6dc97-4239-a6c5-2faae47b111a'}, 'organization': {'id': '045796c3-a448-b93c77d6b0d2'}, 'apiHost': 'https://api.com'}, {'id': '1e0f069e-458d-954b-353500717c20', 'name': 'US', 'dataGeography': 'IE', 'dataRegion': '02', 'billingType': 'trial', 'partner': {'id': '31e6dc97-3907-a6c5-2faae47b111a'}, 'organization': {'id': '045796c3-a448-b93c77d6b0d2'}, 'apiHost': 'https://api.com'},
This is repeated for each tenant.
Any help would be much appreciated.
Best wishes
Michael
I am very new to Python and I apologise if I am asking this wrong. I have retrieved a list of tenants via the API I am trying to use. I need to retrieve the ID, Name and Region from the result. I have 10 tenants.
I managed to do this earlier in my code, but that didn't returned any items, just a set of tokens that were easy to retrieve. How do I get just the tokens I want from this list? Below is my code
r = requests.get(tenants_url, headers=headers) tenants = r.json()If I look in the debugger I get this
<class 'dict'>: {'items': [{'id': '0e717975-4dce-b911-23276700d154', 'name': 'UK', 'dataGeography': 'IE', 'dataRegion': '01', 'billingType': 'trial', 'partner': {'id': '31e6dc97-4239-a6c5-2faae47b111a'}, 'organization': {'id': '045796c3-a448-b93c77d6b0d2'}, 'apiHost': 'https://api.com'}, {'id': '1e0f069e-458d-954b-353500717c20', 'name': 'US', 'dataGeography': 'IE', 'dataRegion': '02', 'billingType': 'trial', 'partner': {'id': '31e6dc97-3907-a6c5-2faae47b111a'}, 'organization': {'id': '045796c3-a448-b93c77d6b0d2'}, 'apiHost': 'https://api.com'},
This is repeated for each tenant.
Any help would be much appreciated.
Best wishes
Michael