0
votes

I'm trying to build a webapp based on Google Sheets. I'm a little bit confused with the API. I have a spreadsheet which is shared with me by Drive and contains 2 sheets. I can get the first sheet with

GET /v4/spreadsheets/{spreadsheetId}
Returns the spreadsheet at the given ID.

endpoint. But I couldn't figure out how to get the second sheet. Is there a way I can get spesific sheet from a spreadsheet?

1
The response should contain both sheets in the spreadsheet. Can you paste the response you're seeing vs what you expect to see?Sam Berlin
@SamBerlin I was using 'ranges' parameter and the length of sheets list of the returning object was 1. I figured it out though. The solution is specifying the sheet name along with the range. In my case it is ...&ranges=iOS!A5:N44&... Should I post an answer?Ertuğrul
Yup, post away! The range parameter is specified in A1 notation, so as documented in the intro, skipping the sheet name will use the first visible sheet. Since all the requests were for the same sheet, only one sheet was returned.Sam Berlin

1 Answers

2
votes

The problem in here is when you are using ranges parameter you have to specify the sheet title with A1 notation syntax as described in this document: https://developers.google.com/sheets/guides/concepts#sheet_id

I was using the ranges parameter and using the A1 notation correctly but I wasn't specifying the sheet title. In that scenario the default sheet is the first one. If you want the get another sheet other than the first one you have to specify the title, like this:

https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}?ranges=sheetTitle!A3:F20