I'm trying to query Azure AD for some data which returns JSON. I want to take some part of this data and fill up an excel sheet. I've checked many examples which dumps all the data from JSON to an excel sheet (using xlwt), but how do I do this for only some part of JSON data?
Here's the script that I'm using:
import requests
def get_application_list():
application_list_response = requests.get("https://graph.microsoft.com/beta/applications", verify=False,
headers={"Authorization": "Bearer" + access_token})
application_list_response_json = application_list_response.json()
for item in application_list_response_json['value']:
print("Application Name:", item['displayName'])
print("Application ID:", item['id'])
get_application_list()
I would like to get the Application name and the application id in the excel sheet. Sample output:
P.S: I'm very new to Python. Any suggestion to optimize this code would also be helpful.
Thanks!
