C# API access to row attachments
Greetings,
I have been able to use the Smartsheet C# API to access sheet and cell data without issues. I added an attachment to a row and attempted to get information about it via the API:
// Load the entire sheet
Sheet sheet = smartsheet.SheetResources.GetSheet(selectedSheetID, null, null, null, null, null, null, null);
// Build column map for later reference
foreach (Column column in sheet.Columns)
columnMap.Add(column.Title, (long)column.Id);
// Find and store all attachment metadata in custom AttachmentData class objects
List<AttachmentData> allAttachments = new List<AttachmentData>();
foreach (Row row in sheet.Rows) {
foreach (Attachment curAttachment in row.Attachments) {
Sheet.Attachments is null and when going into a specific row, the row.Attachments is also null. I refreshed the sheet and it shows the attachment and the row cell data is correctly pulled by the API. I also note that row.ModifiedAt is set to yesterday despite my having just aded the attachment within the hour.
I'm just wondering whether I am going about this the wrong way or whether there is a way to specify programatically to get the latest version of the sheet. I know GetSheet() has an ifVersionAfter parameter but does it need to be explicitly set?
Any guidance is appreciated - thanks.
Answers
-
Hi @kj2757
Get Sheet will only returns attachments if you use the
include=attachments
query parameter:Alternatively, you could use a separate API call to List Attachments: https://smartsheet.redoc.ly/tag/attachments#operation/attachments-listOnSheet
Let us know if that helped!
Cheers,
GenevieveJoin us for Jumpstart 2025 with Community on 23 January (in two time zones)! 🎉 Register here.
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 65.3K Get Help
- 445 Global Discussions
- 143 Industry Talk
- 477 Announcements
- 5K Ideas & Feature Requests
- 85 Brandfolder
- 150 Just for fun
- 72 Community Job Board
- 488 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 302 Events
- 36 Webinars
- 7.3K Forum Archives