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 at Smartsheet ENGAGE 2024 🎉
October 8 - 10, Seattle, WA | Register now
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 62.9K Get Help
- 377 Global Discussions
- 207 Industry Talk
- 440 Announcements
- 4.5K Ideas & Feature Requests
- 139 Brandfolder
- 129 Just for fun
- 130 Community Job Board
- 449 Show & Tell
- 30 Member Spotlight
- 1 SmartStories
- 289 Events
- 33 Webinars
- 7.3K Forum Archives