Getting comments from a card
See original GitHub issueHi, 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:
- Created 5 years ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.