1
votes

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

1
That spreadsheet ID looks quite long so I have doubts as to whether it is indeed correct. The IDs I'm familiar with are usually 44 characters. You could try using the openByUrl() method instead. - Diego
Thanks, was a bit of an idiot and used the Script ID.. new IDE got me confused slightly - Connor Dorward

1 Answers

1
votes

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.