I'm using the Python googleapiclient to get the contents of a Sheet. The API currently requires specifying the sheet name. That's fine, but sometimes the name of my sheet changes, and then I get an exception googleapiclient.errors.HttpError: <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/... because the hardcoded sheet name could no longer be found. I want to make it work for all cases.
I couldn't find anything like wildcards, so how can I just get the default/first sheet found in the spreadsheet?
Existing Code:
sheets_service = discovery.build('sheets', 'v4', credentials=credentials)
content = sheets_service.spreadsheets().values().get(spreadsheetId=spreadsheet_id, range='Sheet1').execute()
What I want:
sheets_service = discovery.build('sheets', 'v4', credentials=credentials)
content = sheets_service.spreadsheets().values().get(spreadsheetId=spreadsheet_id, range='*').execute()