Skip to content

Commit

Permalink
fix Google Sheets API URL encoding for sheet cell ranges
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shekharnwagh committed Feb 25, 2025
1 parent 07d3b6a commit d2b294f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/data-sources/api-clients/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d2b294f

Please sign in to comment.