google-api-python-client icon indicating copy to clipboard operation
google-api-python-client copied to clipboard

Create Document, tabs parameter not respected

Open kbridbur opened this issue 10 months ago • 0 comments

Environment details

  • OS type and version: Mac, Apple M3 Max
  • Python version: 3.12.8
  • pip version: 24.3.1
  • google-api-python-client version: 2.160.0

Steps to reproduce

  1. Structure a create document request with any number of tabs in the tabs field
  2. Send request
  3. The request is valid and a document is created, but the document does not have any tabs other than the default "Tab 1"

Code example

from google.oauth2 import service_account
from googleapiclient.discovery import build
import json

SCOPES = ['https://www.googleapis.com/auth/documents']
SERVICE_ACCOUNT_FILE = './credentials.json'

credentials = service_account.Credentials.from_service_account_file(
    SERVICE_ACCOUNT_FILE, scopes=SCOPES
)

docs_service = build('docs', 'v1', credentials=credentials)
request = {
    "title": "test",
    "tabs": [
        {
            "tabProperties": {
                "title": "test tab",
                "index": 0
            },
            "documentTab": {
                "body": {}
            }
        },
        {
            "tabProperties": {
                "title": "test tab2",
                "index": 1
            },
            "documentTab": {
                "body": {}
            }
        }
    ]
}

response = self.docs_service.documents().create(
            body=request).execute()
print(response["documentId"])
print(json.dumps(response["tabs"], indent=4))

See that only the default tab exists. If any names of parameters are changed/etc you will receive a 400 error which indicates that the client is indeed parsing the tabs parameter provided, but nothing appears to be done with it

kbridbur avatar Jan 30 '25 22:01 kbridbur