我正在尝试使用 Smartsheet API 在 Java 中编写一个简单的程序,该程序通过一个相当大的工作表,并缩进某些行。这是一些类似于我正在使用的代码。
Smartsheet smartsheet = new SmartsheetBuilder().setAccessToken("[My Access Token]").build();
sheetId = 00000000000000; // My Sheet ID
Sheet sheet = smartsheet.sheetResources().getSheet(sheetId, null, null, null, null, null, null, null);
List<Row> rows = sheet.getRows();
Row row = new Row();
row.setId(rows.get(2).getId()); // Updating the second row of the sheet.
row.setIndent(1);
row.setParentId(rows.get(1).getId()); // Set the parent as the row immediately above (which is not indented).
Cell cell = new Cell();
cell.setColumnId(rows.get(1).getCells().get(0).getColumnId());
cell.setValue("Test");
List<Cell> cells = Arrays.asList(cell);
row.setCells(cells);
rows = Arrays.asList(row);
smartsheet.sheetResources().rowResources().updateRows(sheetId, rows);
当我运行它时,我总是在最后一行收到以下错误。
Exception in thread "main" com.smartsheet.api.InvalidRequestException: Invalid row location.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.smartsheet.api.internal.AbstractResources$ErrorCode.getException(AbstractResources.java:147)
at com.smartsheet.api.internal.AbstractResources.handleError(AbstractResources.java:894)
at com.smartsheet.api.internal.AbstractResources.putAndReceiveList(AbstractResources.java:745)
at com.smartsheet.api.internal.SheetRowResourcesImpl.updateRows(SheetRowResourcesImpl.java:252)
at Test3.main(Test3.java:67)
缩进似乎是造成这种情况的原因,就好像我删除了 setIndent(...) 行一样,它运行良好。我在这里做错了吗?预先感谢您的帮助。