Update card's checklist item state with Trello.Net on Trello API

1.5k views Asked by At

Is there a way to update the CheckItemStates of a Trello card? (With Trello.NET)

trello.Checklists.AddCheckItem takes only a checklist ID and a name for the item. And it returns void.

Looking at a card with an existing checklist (all the items still unchecked) the CheckItemStates has 0 items.

1

There are 1 answers

4
dillenmeister On

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.

As of release 0.5.5-beta Trello.NET supports this. Use Trello.Cards.ChangeCheckItemState. More info here.

Edit:

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);
}