Home > database >  Delete data from a sheet in google sheets with API - using Postman
Delete data from a sheet in google sheets with API - using Postman

Time:05-20

I would like to erase all the data of a sheet in a google sheet via the googlet sheets APIs: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/clear

Unfortunately I can not select the id of my sheet. I used the proposed method: POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetid}/values/{range}: clear

but it only removes the data from my first sheet.

How can I put the id of my other leaves in the method?

My google sheets ID

My first sheets in my google sheets

ID of my second sheets

My second sheets in my google sheets

CodePudding user response:

From your reply, the request of "Method: spreadsheets.values.clear" is as follows.

POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:clear

spreadsheetId : The spreadsheet the updates were applied to.

range: The range (in A1 notation) that was cleared. (If the request was for an unbounded range or a ranger larger than the bounds of the sheet, this will be the actual range that was cleared, bounded to the sheet's limits.)

In this case, it is not required to use the sheet ID. The sheet name is used.

From your showing images, it seems that the sheet names of your 1st and 2nd sheet are Feuille 1 and Feuille 2, respectively. For example, when you want to clear 2nd sheet of Feuille 2, please use the following request.

POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/Feuille 2:clear

Note:

  • For example, when you want to retrieve the sheet names from a Google Spreadsheet, you can use "Method: spreadsheets.get". Ref

Reference:

  • Related