2

When read/write from the google sheets, have this error:

gspread.exceptions.RequestError: (404, '404: b\'<!DOCTYPE html>
...
Sorry, unable to open the file at present.</p><p> Please check the address and try again.</p>

The code has been working for many years but it suddenly gets this error without any changes being made. The following is the code. I've created a new credential json file but it also does not work.

SCOPES = ['https://www.googleapis.com/auth/spreadsheets', "https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]

credentials = ServiceAccountCredentials.from_json_keyfile_name("credentialfile.json", SCOPES)
connection = gspread.authorize(credentials)
worksheet = connection.open(self.sheet).worksheet(tab)

Any suggestions?

Rubén
  • 34,714
  • 9
  • 70
  • 166
0xdev
  • 51
  • 1
  • 3

1 Answers1

1

I had the exact same issue. It was because of a change on Google's side to require v4 of the sheets API. (The link that @MattKing pointed me to the answer)

Solution that worked for me: pip install -U gspread. I was on 0.6.2, it upgraded to 4.0.1 and everything worked on the first try.

Nick Loadholtes
  • 188
  • 1
  • 12