1

I'm trying to use the Google Sheets API (v4) for Android, and I can't find how to use the values().update() or batchUpdate() methods to update a specific workbook of the sheet.

Does anyone know how to do this?

EDIT: To clarify, I am using THIS API: (from build.gradle)

compile('com.google.api-client:google-api-client-android:1.22.0') {
    exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-sheets:v4-rev28-1.22.0') {
    exclude group: 'org.apache.httpcomponents'
}
19lmyers
  • 367
  • 1
  • 16

2 Answers2

6

Turns out I have to specify the sheet in the ValueRange:

   "range": "Sheet2!A1"

Hopefully that example can help anyone else who had this problem.

19lmyers
  • 367
  • 1
  • 16
2

Be noted that the v4 version is JSON-based and often require you to specify a spreadsheet ID of the spreadsheet you are working with. They also often require the ID of the sheet being manipulated. These values appear either as part of the API endpoint URL, as query parameters, or as part of a request body.

values().update()

You must specify the spreadsheet ID, range, and a valueInputOption. Your request should be PUT https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}.

batchUpdate()

You must specify the spreadsheet ID, a valueInputOption, and one or more ValueRanges. You request should be POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values:batchUpdate.

Here are some related theads which might help:

Community
  • 1
  • 1
adjuremods
  • 2,938
  • 2
  • 12
  • 17
  • 2
    But how do I specify the workbook for a given spreadsheet? Neither the valueInputOption nor the ValueRange seems to have a way to do this. – 19lmyers Oct 01 '16 at 00:00