Connor Dorward
Connor Dorward

Reputation: 37

Google Apps Script : Unexpected error while getting the method or property openById on object SpreadsheetApp

My google sheets apps script has a doGet() function which takes an HTTP get request and parses the query parameters and puts them in a spreadsheet.

When I tested the app with a get request, I got a '500 Internal Error message', I then tested the deployment and got the error message ' Exception: Unexpected error while getting the method or property openById on object SpreadsheetApp. (line 9, file "Code") '.

So, it's having a problem opening the sheet but I am certain I have the correct sheet ID looking at project settings. I thought it could be a google drive issue so I made an entirely new google account with a blank drive and a new spreadsheet but the same error appears!? I'm not sure what's going on here, so any help would be much appreciated! Code below:

https://github.com/Conwon99/4th-Year-Project/blob/main/GoogleAppsScript

Upvotes: 3

Views: 17655

Answers (1)

CMB
CMB

Reputation: 5163

As the comments indicate, the sheet ID in the code is not in the standard 44-character format thus error 500 was thrown by openById() method.

The solution is to use a valid file ID that points to a non-deleted Google Sheet.

Upvotes: 4

Related Questions