[Python] Update a Google docs on Google Drive by api

Discussão em 'Python' iniciado por Stack, Fevereiro 1, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to create a Google Docs on Google drive, with some text inside the Docs. I'm already creating the Docs via api, but i only can update a blank archive.

    Does anyone know how to update the text inside the doc and/or add the information when the docs is created?

    This piece of code creates the blank docs in python:

    doc_metadata = {
    'name': 'docs_name',
    'parents': [f'{folder_id}'],
    'mimeType': 'application/vnd.google-apps.document'
    }

    try:
    doc = drive_service.files().create(body=doc_metadata).execute()
    documentId = doc.get("id")
    except HttpError as error:
    print(f'An error occurred: {error}')

    Continue reading...

Compartilhe esta Página