private Card setCheckListOnCard(Card c,CheckList cl){
List<String> arrayIdOfCheckList=new ArrayList<>();
String cardId=c.getId(); //returns empty
cl.setId(String.valueOf(UUID.randomUUID());
String checkListId=cl.getId();
arrayIdOfCheckList.add(checkListId);
c.setIdChecklists(arrayIdOfCheckList);
Card updatedCard=c.update();
return updatedCard;
}
How can we associate checklist to card?
Assume that the card already exists on trello server side in this snippet thus the card has an ID.
On the other hand,my check list exists only on my client side at this point so the checklist does not have an ID,
I tried to set unique id to the checklist here.
With c.setIdChecklists(arrayIdOfCheckList), Card c is successfully associated with
an arrayIdOfCheckList however, after card is updated, returned (Card)updatedCard losts
arrayIdOfCheckList.
Do you have any idea of what's wrong with my snippet?
Hi Oscar
The library used here is https://github.com/taskadapter/trello-java-wrapper.
And you are true.
There's a method that send prepared checklist to trello instance
and returns singed checklist by server.
CheckList signedCheckList=trello.createCheckList(c.getId(),preparedChecklist);
signedCheckList has a key and successfully set to a card.
Thanks.
Hi Ringo,
I'm not familiar with the library you're using to interact with the Trello API, but you don't get to set your own IDs for checklists. Just like for any other Trello element, they are set by the server.
What you do is to POST to /1/checklists with a payload containing a checklist name and the id of the card. This will return an id for the checklist. Optionally, you can copy an existing checklist by specifying the id of the source checklist.
https://trello.readme.io/v1.0/reference#checklists
Then, you can POST the items one by one to /1/checklists/ID/checkItems, where ID is the previously returned checklist id.
https://trello.readme.io/v1.0/reference#checklistsidcheckitems
In your library, it's likely that there is another function to create a checklist and to add items to it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.