我尝试使用java和Google表格API v4向表格写一行。我收到的错误是我无法理解的。任何帮助将不胜感激!
传递的值是:
sRange =' 09/03/2017 11:01:13 PM'!A1
body = {majorDimension = ROWS,values = [[Test ID,Test Name,Run ID,Status,Run Duration,Execution Date,Execution Time]]}
这是故障代码:
outputValues = Arrays.asList(Arrays.asList("Test ID", "Test Name", "Run ID", "Status", "Run Duration", "Execution Date", "Execution Time"));
sRange = "'" + sSheetName + "'" + "!" + sHeaderRow;
body = new ValueRange().setValues(outputValues).setMajorDimension("ROWS");
result = service.spreadsheets().values().update(sSpreadsheetID, sRange, body).setValueInputOption("RAW").execute();
结果:
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Requested writing within range ['09/03/2017 11:01:13 PM'!A1], but tried writing to column [B]",
"reason" : "badRequest"
} ],
"message" : "Requested writing within range ['09/03/2017 11:01:13 PM'!A1], but tried writing to column [B]",
"status" : "INVALID_ARGUMENT"
}
答案 0 :(得分:1)
由于工作表标题中的字符问题,解决了此错误。删除工作表标题中的空格,破折号和冒号,并用下划线替换,以解决问题。
答案 1 :(得分:0)