How to find Trello ListId's or CardId's with Trello.NET

2.3k Views Asked by At

I'm trying to find all cards in a specific list using Trello.NET In the examples given it's clear to to find all list names in a Board, and all Cards in a Board. However if I want to find all Cards in a specific List, as far as I can see I need ListID (can't filter by List Name) by using trello.Lists.WithId()

Knowing the List name, how can I determine what it's ListId is so I can subsequently filter for all Cards in it?

And if I would subsequently like to edit an existing Card, how can I determine the CardId.

1

There are 1 best solutions below

0
dillenmeister On BEST ANSWER

Use LINQ and filter in-memory:

// More than one list can have the exact same name, this finds the first:
var list = trello.Lists
   .ForBoard(board)
   .FirstOrDefault(list => list.Name == "name of the list");

if (list != null)
{
    var cards = trello.Cards.ForList(list);
    // ...
}

You could use a similar technique to find a card if you know it's name: use trello.Cards.ForBoard or trello.Cards.ForList first, and then filter by name afterwards.

For cards there is another option though: trello.Cards.Search. For example:

var cards = trello.Cards.Search("name of the card");

The search will be performed on the server in this case.