Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Attachments

Oskar Dillén edited this page May 7, 2014 · 6 revisions

Checklists in Trello are a bit weird. A checklist belongs to a board. The same checklist can be on several cards. But each card has separate checklist item states (checked/unchecked). I don't think it's possible to add the same checklist to more than one card on trello.com, but that's how it's modeled behind the scenes.

This example shows how to loop through a card´s check lists and check items.

foreach (var checkList in trello.Cards.WithId("a card id").Checklists)
{
	Console.WriteLine(checkList.Name);
	foreach (var checkItem in checkList.CheckItems)				
		Console.WriteLine("\t{0}: {1}", checkItem.Name, checkItem.Checked);
}

Example: Remove all attachments with the name "DevSupport" from a card

var card = trello.Cards.WithId("a card id");
foreach (var attachment in card.Attachments.Where(a => a.Name == "DevSupport"))
    trello.Cards.RemoveAttachment(card, attachment);

There are two ways to upload an attachment, either using a file path:

trello.Cards.AddAttachment(card, new FileAttachment(@"C:\temp\image.jpg", "An image"));

Or an array of bytes:

trello.Cards.AddAttachment(card, new BytesAttachment(
    File.ReadAllBytes(@"C:\temp\image.jpg"), "An image", "image.jpg"));
Clone this wiki locally