I'm trying to read a google sheet in my app. The sheet itself is public and i'm trying to access it using an API key rather than OAuth2 as theres no requirement to write to it.
Initially i'm just trying to get a list of all sheets available in that particular spreadsheet id
I have the below code, but it results in an error 400 The request URL is invalid.
class GoogleAPI
{
static string ApplicationName = "home-Timetable";
private static readonly string API_KEY = "AIzaSyDHBvpqlZ5MM04ZrsuGRzpPp_WDI7mS5D0"; // Test Key
static readonly string spreadsheetId = "19c3dGbBHhU7EtrCJBa7-bKMn7Jlg3R9xMXOP9HBZDPc"; // Test Sheet
public static void GetSheets()
{
var sheetsService = new SheetsService(new BaseClientService.Initializer()
{
ApplicationName = ApplicationName,
ApiKey = API_KEY,
HttpClientFactory = new ProxySupportedHttpClientFactory(),
});
SpreadsheetsResource.GetRequest request = sheetsService.Spreadsheets.Get(spreadsheetId);
Data.Spreadsheet response = request.Execute();
Console.WriteLine(JsonConvert.SerializeObject(response));
}
}
The correct url for the sheet is: https://sheets.googleapis.com/v4/spreadsheets/19c3dGbBHhU7EtrCJBa7-bKMn7Jlg3R9xMXOP9HBZDPc?key=AIzaSyDHBvpqlZ5MM04ZrsuGRzpPp_WDI7mS5D0
This gives the expected response.
how do i successfully get the response expected?