Java Smartheets - Column ID is not created when creating new Sheet

73 Views Asked by At
  1. The following code

    Sheet aSheet = new Sheet(); List columns = new ArrayList<>();
    Column claim_number = new Column().setTitle("EMS Claim Number"); claim_number.setType(ColumnType.TEXT_NUMBER); claim_number.setPrimary(Boolean.TRUE); claim_number.setId(4583173393803100L); columns.add(claim_number); aSheet.setColumns(columns); aSheet.setName("Name"); Sheet created = smartsheet.sheetResources().createSheet(aSheet);

Results in the error

  "message" : "The columnId 4583173393803100 is invalid."

SmartSheets gives an example of a columnID so I tried to use numbers of the same number of digits

  1. If I create the columns without an ID and then later try to populate rows in the new sheet

    Row row = new Row.AddRowBuilder().setCells(cells).setToBottom(true).build();
    smartsheet.sheetResources().rowResources().addRows(created.getId(), Arrays.asList(row));
    

I get the error that the column id are null

"message" : "Required object attribute(s) are missing from your request: cell.columnId.",

Maven:

        <dependency>
            <groupId>com.smartsheet</groupId>
            <artifactId>smartsheet-sdk-java</artifactId>
            <version>2.101.0</version>
        </dependency>
  

Questions:

  1. How do I create and set a valid column ID?

  2. Why does the API or smartsheet system not autogenerate the column ID and if is does how do I access those values?

Regards Conteh

1

There are 1 best solutions below

0
On

columnId is read only (generated by the Smartsheet API) and should be null in your request to create a sheet.