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,
GenevieveNeed more information? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao!👋 | Global Discussions
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 67.9K Get Help
- 474 Global Discussions
- 208 Use Cases
- 517 Announcements
- 5.6K Ideas & Feature Requests
- 87 Brandfolder
- 157 Just for fun
- 84 Community Job Board
- 521 Show & Tell
- 36 Member Spotlight
- 3 SmartStories
- 309 Events
- 37 Webinars
- 7.3K Forum Archives