Creating new sheet using Java API - Unable to create child tasks
I am trying to create a smartsheet using Java API that fills data in parent/child task format. I tried couple of options, but I was getting exception. I am not sure if it is possible.
So, I tried another option, where I created the sheet and then re-read the sheet and tried to indent the rows using following code -
// Indent child Rows
List<Row> rows = checkPointSheetData.getSheet().getRows();
SmartsheetUtility smartsheetUtility = new SmartsheetUtility();
List<Row> indentedRows = new ArrayList<>();
for(Row taskRow : rows) {
try {
WorkItemData workItemData = smartsheetUtility.getWorkItemData(taskRow, null, checkPointSheetData.getSheet().getColumns(),
checkPointSheetData.getColumnMap().get(SmartSheetAppConstants.SMARTSHEET_COL_TASK_NAME)); // WorkItemData is a POJO class contains the row data of smartsheet
if(workItemData.getTaskName() != null && !workItemData.getTaskName().startsWith(getCheckPointPattern())) {
Row newRow = new Row(taskRow.getId());
newRow.setIndent(1);
indentedRows.add(newRow);
checkPointSheetData.getSmartsheet().sheetResources().rowResources().updateRows(getCheckPointSheetId(), indentedRows);
}
} catch (ParseException parseException) {
APPLOGGER.error(parseException.getMessage(), parseException);
}
}
While running above code I am getting exception -
2019-07-15 10:54:00 WARN DefaultHttpClient:153 - {request:{command:'PUT https://api.smartsheet.com/2.0/sheets/1134696521328516/rows',headers:{'Accept-Encoding':'gzip,deflate','Authorization':'Bearer ****wll2','Connection':'Keep-Alive','Content-Length':'36','Content-Type':'application/json','Host':'api.smartsheet.com','User-Agent':'Smartsheet Java SDK/2.2.9/smartsheet-sdk-java-2.2.9.jar!com.smartsheet.api.SmartsheetFactory/Windows 10 Java HotSpot(TM) 64-Bit Server VM Oracle Corporation 1.8.0_151',},body:'[{"id":3407430094219140,"indent":1}]'},response:{status:'HTTP/1.1 404 Not Found',headers:{'Connection':'Keep-Alive','Content-Type':'application/json;charset=UTF-8','Date':'Mon, 15 Jul 2019 05:23:58 GMT','Keep-Alive':'timeout=5, max=27','Vary':'Accept-Encoding',},body:'{
"errorCode" : 1006,
"message" : "Not Found",
"refId" : "15bj685inr0r1",
"detail" : {
"index" : 0,
"rowId" : 3407430094219140
}
}'}}
2019-07-15 10:54:00 ERROR IdentifyCheckPointGoals:124 - Not Found
com.smartsheet.api.ResourceNotFoundException: Not Found
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:148)
at com.smartsheet.api.internal.AbstractResources.handleError(AbstractResources.java:895)
at com.smartsheet.api.internal.AbstractResources.putAndReceiveList(AbstractResources.java:746)
at com.smartsheet.api.internal.SheetRowResourcesImpl.updateRows(SheetRowResourcesImpl.java:252)
at com.smartsheet.main.IdentifyCheckPointGoals.updateCheckPointGoalSheet(IdentifyCheckPointGoals.java:281)
at com.smartsheet.main.IdentifyCheckPointGoals.updateCheckPointGoals(IdentifyCheckPointGoals.java:149)
at com.smartsheet.main.IdentifyCheckPointGoals.main(IdentifyCheckPointGoals.java:121)
Can anyone please help me here to understand how I can establish parent/child task while creating a new smartsheet ?
Comments
-
You can have a sheet that ultimately has hierarchy; however, the flow would be to create the sheet first > then add the rows with the data > and then update the rows to create the hierarchy. So doing it all in one action is why there is a problem. Both the sheet and the rows have to exist first as you'll need sheetId and rowIds to carry out the request.
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 63.9K Get Help
- 410 Global Discussions
- 219 Industry Talk
- 457 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 136 Just for fun
- 57 Community Job Board
- 459 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 298 Events
- 37 Webinars
- 7.3K Forum Archives