question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting comments from a card

See original GitHub issue

Hi, I was wondering if you could tell me what I’m doing wrong. I’m trying to read all comments, to get the raw text from them and even though I tried several approaches, I can’t get comments from a card. The collection simply appears empty. This is the method I use:

public async Task<List<(DateTime CreationDate, string Text)>> GetRawComments(string listName, params string[] cardNames)
{            
    IMe me = await Factory.Me();
    IBoard board = me.Boards.Single(b => b.Name == BoardName);
    await board.Refresh();
    IList list = board.Lists.Single(l => l.Name == listName);
    await list.Refresh();
    List<ICard> cards = list.Cards.Where(c => cardNames.Any(name => c.Name.Contains(name))).ToList();

    var comments = new List<(DateTime CreationDate, string Text)>();
    foreach (ICard card in cards)
    {
        await card.Refresh();                                
        foreach (IAction comment in card.Comments) // card.Comments is empty
        {
            DateTime creationDate = comment.CreationDate;
            string text = comment.Data.Text;
            comments.Add((creationDate, text));
        }
    }            
    return comments;

Everything up until the comments is loaded fine, but the card.Comments collection is empty, so the foreach block isn’t even executed, even though it should contain few hundreds of comments. I configure Trello credentials in the constructor, and since it loads the cards just fine, I assume that part is probably fine.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Racoon77commented, Dec 9, 2018

Thank you. The problem was that I was refreshing the card and it didn’t occur to me comments should be refreshed as well. That Limit example comes from an old StackOverflow question which I went to because I couldn’t find many examples in the GitHub Pages documentation. Now I see the tests could serve as examples pretty well, too.

Thanks for your help, now it should be okay.

0reactions
gregsdenniscommented, Dec 9, 2018

That’s odd. I would think the card refresh would download the comments given the set downloaded fields. I’ll run some more experiments.

Glad you got it working, though. Thanks for the links.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trello API get card comments
is there a way to get all the comments of a card through the Trello API? I can get the card, the list...
Read more >
Commenting on cards | Trello
Comments allow you to engage in a conversation on the back of a card. To view the back of a card, click on...
Read more >
How to get all the comments of a card through the Trello API?
How to get all the comments of a card through the Trello API? ➤ We have more than 4 answers ➤ Learn More...
Read more >
Is there a way to make the comments added to a card get ...
Is there a way to make the comments added to a card get added to its copy? In my workspace I have different...
Read more >
Pulling Trello Card Comments Using Power Automate
Trello stores comments in date order with the newest comment listed first. We can use the first() function to get the first comment...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found