Welcome to the Smartsheet Forum Archives


The posts in this forum are no longer monitored for accuracy and their content may no longer be current. If there's a discussion here that interests you and you'd like to find (or create) a more current version, please Visit the Current Forums.

Unknown Attribute Error on Update Sheet API request

Options
Nathan Reid
edited 12/09/19 in Archived 2017 Posts

I am currently using the smartsheet-csharp-sdk class library to interact with the API and I keep getting an exception when I am trying to rename a sheet through Update Sheet.

I do a GetSheet call, change the name to the new sheet name and pass that sheet as the parameter for UpdateSheet. The error I get is "Unknown attribute \"sheetname\" found at..."

The API documentation shows that it is capable of renaming a sheet name, so I'm confused as to why I'm getting this error. I'm not super familiar with writing PUT requests, but I noticed on the API doc that the example PUT request for Update Sheet has the parameter "name" and not "sheetname". Not sure if this has anything to do with it or not.

Thanks,

Nathan

Comments

  • Shaine Greenwood
    Shaine Greenwood Employee
    edited 06/19/17
    Options

    Hi Nathan,

    I'm not exactly sure what your code looks like, but you can only change the sheet name if you're the Owner of the sheet. If you're sure that you own the sheet, then make sure that you're using the correct PUT and code. 

    You need to PUT on /sheets/{sheetid} and then use something like the following in C# (this is somewhat copied out of the documentation): 

    Sheet sheet = new Sheet.UpdateSheetBuilder(sheetId)

    .SetName("New Sheet Name")

    .Build();  

    smartsheet.SheetResources.UpdateSheet(sheet);

    If you continue to have problems, contact our Support team and they might be able to review your code. I must confess that my experience lies in JavaScript and not C# but we have people on our Support team with API knowledge, so they can work with you to figure out the error.

  • Nathan Reid
    Options

    Found my problem. I was pulling the sheet by SheetResources.GetSheet(sheetId) and then trying to change the Name and then using SheetResources.UpdateSheet(sheet) instead of using the UpdateSheetBuilder. Thanks!

  • Shaine Greenwood
    Shaine Greenwood Employee
    edited 06/19/17
    Options

    Whoops, looks like I made that mistake in my code example above! Fixed.

    Glad you found the issue.



    EDIT: Apparently I need more coffee. I didn't make a mistake but just misread my example code. cheeky

This discussion has been closed.