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 help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64.1K Get Help
- 414 Global Discussions
- 221 Industry Talk
- 460 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 141 Just for fun
- 58 Community Job Board
- 462 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 299 Events
- 38 Webinars
- 7.3K Forum Archives