Closed
Description
As reported at https://issuetracker.google.com/issues/217399871
The sheets.spreadsheets().values().append
operation is failing if the sheet name includes a plus ("+") sign and has a dependency on google-http-client
version 1.34.0
or older.
The breaking change is likely the result of #913
Library versions:
implementation 'com.google.apis:google-api-services-drive:v2-rev212-1.21.0'
implementation 'com.google.apis:google-api-services-sheets:v4-rev612-1.25.0'
testImplementation 'com.google.api-client:google-api-client:1.25.0'
testImplementation 'com.google.http-client:google-http-client:1.34.0'
testImplementation 'com.google.http-client:google-http-client-jackson2:1.34.0'
Reproducer:
@Test
void testAppendWithPlusSignSheet() throws Exception {
String fileName = "test-append-plus-sign";
String sheetName = "plus+sign";
String spreadsheetId = spreadsheetHelper.createSpreadsheet(fileName, sheetName);
String range = sheetName + "!A1";
ValueRange valueRange = new ValueRange();
valueRange.setMajorDimension(SheetOptions.MAJOR_DIMENSION_ROWS);
valueRange.setRange(range);
valueRange.setValues(ImmutableList.of(ImmutableList.of("test")));
try {
Sheets sheets = authHelper.getSheetsService();
sheets.spreadsheets().values()
.append(spreadsheetId, range, valueRange)
.setValueInputOption(SheetOptions.VALUE_INPUT_RAW)
.setInsertDataOption(SheetOptions.INSERT_DATA_ROWS)
.setIncludeValuesInResponse(true)
.setResponseValueRenderOption(SheetOptions.VALUE_RENDERING_UNFORMATTED)
.setResponseDateTimeRenderOption(SheetOptions.DATE_RENDERING_SERIAL)
.execute();
} finally {
Drive drive = authHelper.getDriveService();
FileList fileList = drive.files().list().execute();
for (File file : fileList.getItems()) {
if (file.getTitle().equals(sheetTitle)) {
drive.files().delete(file.getId()).execute();
}
}
}
}
This was working fine up to google-http-client
version 1.33.0
, when used with a newer version it fails with the following exception:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Request range[plus sign!A1] does not match value's range[plus+sign!A1]",
"reason" : "badRequest"
} ],
"message" : "Request range[plus sign!A1] does not match value's range[plus+sign!A1]",
"status" : "INVALID_ARGUMENT"
}