Python Google Sheets API: Duplicate Sheet

Jul 17, 2019
credentials = ...service = build('sheets', 'v4', credentials=credentials)sheet = service.spreadsheets()SPREADSHEET_ID = ...OLD_SHEET_ID = ...NEW_SHEET_NAME = ...# Insert New Empty Row at A2body = {    'requests': [        {            'duplicateSheet': {                'sourceSheetId': OLD_SHEET_ID,                'insertSheetIndex': 1,                'newSheetName': NEW_SHEET_NAME            }        }    ]}# Using sheet.values().batchUpdate will trigger: Invalid JSON payload received. Unknown name "requests": Cannot find field.result = sheet.batchUpdate(spreadsheetId=SPREADSHEET_ID,                           body=body).execute()

NOTE: Refer Setup and Access Google Sheets API With Python.


❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.