]> git.cworth.org Git - turbot/commitdiff
Finally I found out how to make the stupid batch API work
authorjustin melvin <jmelvinprime@gmail.com>
Sat, 28 Nov 2020 06:16:48 +0000 (22:16 -0800)
committerjustin melvin <jmelvinprime@gmail.com>
Sat, 28 Nov 2020 06:16:48 +0000 (22:16 -0800)
turbot/sheets.py

index 434665ef448cd21b4b74e1b90e7d2843c7202acf..921b51a24d339cab67e212ca8e8cb704cc4a74c3 100644 (file)
@@ -81,13 +81,23 @@ def sheets_create_for_puzzle(turb, puzzle):
 
 def renameSheet(turb, url, newName):
     id = extractIdFromSheetUrl(url)
-    turb.sheets.batchUpdate(body={
-                                "updateSheetProperties": {
-                                    "properties": {
-                                        "spreadsheetId": id,
-                                        "title": newName
-                                    }
-                                }}).execute()
+    requests = []
+    requests.append({
+        'updateSpreadsheetProperties': {
+            'properties': {
+                'title': newName
+            },
+            'fields': 'title'
+        }
+    }
+
+    body = {
+        'requests': requests
+    }
+
+    turb.sheets.batchUpdate(spreadsheetId = id,
+                            body=body
+                            ).execute()
 
 def extractIdFromSheetUrl(url):
     # Google sheet ids are between the /d/ and /edit in the url, like https://docs.google.com/spreadsheets/d/1dxHBzjenjhCAJQ8lM0skJO2mxlup8aWZm0-LaXeVPrg/edit#gid=0