Michael Whatcott
Michael Whatcott

Reputation: 5985

How to detect state of checklist item using Trello API

I'd like to see some sort of 'state' field on each item in the checklist object returned from a query in this form:

https://api.trello.com/1/checklists/[checklist_id]

# Response:

{u'checkItems': [{u'id': u'blahblahblah1',
                  u'name': u'Some checklist item',
                  u'pos': 424242,
                  u'type': u'check'},
                 {etc..}
]}

Also, it seems that the following method does return the state, but only for completed checklist items:

https://api.trello.com/1/cards/[card_id]/checkItemStates

# Response:

[{"idCheckItem":"blahblahblah1","state":"complete”},
 {“idCheckItem":"blahblahblah2","state":"complete"},
 {"idCheckItem":"blahblahblah3","state":"complete”},
 {“idCheckItem":"blahblahblah4","state":"complete"}]

So does this mean that the results of several queries have to be synthesized in order to get an accurate view of the state of all the checklist on a given card? I'd love to get all the information about all checklists (including the state of each item) on a card in a single query. Am I missing something?

Upvotes: 1

Views: 1128

Answers (1)

gregsdennis
gregsdennis

Reputation: 8428

If you add the /checkItems switch to the path, you will see the states for each item:

/1/checklists/[checkListId]/checkitems?key=[your appKey]

Returns:

[
    {"state":"complete","id":"XXX","name":"hex support","pos":16804},
    {"state":"incomplete","id":"XXX","name":"funky chars","pos":33233}
]

They have since added it to the base call (as you have it) as well.

Upvotes: 1

Related Questions