From 4116ed0909d710e958eb2d8b5a34a9ae268eb7aa Mon Sep 17 00:00:00 2001 From: Shekhar Wagh Date: Wed, 26 Feb 2025 00:46:58 +0530 Subject: [PATCH] fix Google Sheets API URL encoding for sheet cell ranges (#393) URL encode the sheet title and cell range parameters when constructing the Google Sheets API URL to handle special characters in sheet names or ranges which together construct the cell range which is the appended to URL.This prevents API errors when working with sheets that contain spaces or other special characters in their titles. --- src/data-sources/api-clients/google.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data-sources/api-clients/google.ts b/src/data-sources/api-clients/google.ts index d8b34092..2323cbc4 100644 --- a/src/data-sources/api-clients/google.ts +++ b/src/data-sources/api-clients/google.ts @@ -72,7 +72,8 @@ export class GoogleApi { sheetTitle: string, cellRange: string ): Promise< GoogleSheetsValueRange > { - const url = `${ GoogleApi.SHEETS_BASE_URL }/spreadsheets/${ spreadsheetId }/values/${ sheetTitle }!${ cellRange }`; + const range = encodeURIComponent( `${ sheetTitle }!${ cellRange }` ); + const url = `${ GoogleApi.SHEETS_BASE_URL }/spreadsheets/${ spreadsheetId }/values/${ range }`; const result = await this.fetchApi< GoogleSheetsValueRange >( url ); return result; }