dotnet-samples icon indicating copy to clipboard operation
dotnet-samples copied to clipboard

Invalid URL error

Open Desbrina opened this issue 4 years ago • 0 comments

Expected Behavior

Should read the information from the sheet

Actual Behavior

Get an invalid URL error - Always crashes at ValueRange response = request.Execute();

An exception of type 'Google.GoogleApiException' occurred in System.Private.CoreLib.dll but was not handled in user code<HTML><HEAD><TITLE>Bad Request</TITLE><META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD><BODY>

Bad Request - Invalid URL


HTTP Error 400. The request URL is invalid.

</BODY></HTML>

Steps to Reproduce the Problem

` SheetsService service = new(new BaseClientService.Initializer() { ApplicationName = ApplicationName, ApiKey = API_KEY, HttpClientFactory = new ProxySupportedHttpClientFactory(), }); String spreadsheetId = "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"; String range = "Class Data!A2:E"; SpreadsheetsResource.ValuesResource.GetRequest request = service.Spreadsheets.Values.Get(spreadsheetId, range);

        // Prints the names and majors of students in a sample spreadsheet:
        // https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit
        ValueRange response = request.Execute();
        IList<IList<Object>> values = response.Values;
        if (values != null && values.Count > 0)
        {
            Console.WriteLine("Name, Major");
            foreach (var row in values)
            {
                // Print columns A and E, which correspond to indices 0 and 4.
                Console.WriteLine("{0}, {1}", row[0], row[4]);
            }
        }
        else
        {
            Console.WriteLine("No data found.");
        }
        Console.Read();`

Specifications

  • .NET5
  • Windows

Desbrina avatar Jun 28 '21 06:06 Desbrina