This operation is not supported for this document – Sheets API

Tags: , ,



(<class ‘googleapiclient.errors.HttpError’>, <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/1IcMY2TNLYZtGyKO_zcrhP1MudNFXbNdM/values/P%C3%A1gina1%21A%3AP?alt=json returned “This operation is not supported for this document”>, <traceback object at 0x7fbb3dc3bec0>)

I am getting this error message when accessing a spreadsheet in Google Sheets, I know that the error occurs because it is hosted on the google drive and is in xlsx format. Does anyone know any alternative to performing this conversion from xlsx to gsheet directly in the code?

Answer

Yes, you can convert an .xlsx to Google Sheets

For this, use the method Drive v2 method Files: Copy specifying convert true.

Sample:

service.files().copy(fileId=file_id,convert=true, body={"title": "specifyName"}).execute()


Source: stackoverflow