I’ve been writing a ton of late about the Trello API because I’ve basically been head-down in it for the last week. Today I discovered my new biggest annoyance with an otherwise awesome tool.
Using the Trello UI, it’s really simple to move a card from one column/list to another on the same board. Click the card, drag it over, drop. Done.
Want to move it to a different board? That’s not so difficult, either. Open up the card, click the “Move” option, pick your new board and your new list and you’re good.
Moving a card through the API is also pretty easy. Fire off a PUT request to /1/cards/xxxxxx (where xxxxxx is the card’s ID) with the idList parameter set to the ID of the list you want to move it to. The documentation for the Trello API says that the idList parameter is optional and the reason is that you can update a card without moving it.
List IDs are globally unique. You can request information about any list, regardless of what board it’s on, with a GET request to /1/lists/yyyyyy (where yyyyyy is the list ID).
So if I want to move a card to a list, I just need the list ID, right? Right. Except when you need more.
It turns out that there’s another optional parameter, idBoard. If you’re moving a card to a list on a different board, you are required to specify the optional board ID even though the list IDs are unique, so by defining a list ID you automatically know what board that list belongs to.
I got hung up on this for about 30 minutes today and it annoys me. The list ID is the most specific identifier you can get. Why require a more general one on top of it?
So, yeah, if you’re moving a card with the API, you have to use idList. If you’re moving to another board, you have to use idBoard as well. Hopefully me mentioning it helps someone out.
I likewise just spent that 30 minutes beating my head against the same wall.
Once I figured this out on my own, and things still weren’t working, I ran into another problem that I wanted to share back as well.
You can’t use the board short link, you have to use the full id of the board for this to work, otherwise you get the mostly useless error “invalid id” (which also turns up a surprisingly useless amount of google results).
Thanks Clark!
Thanks for confirming my suspicion and saving me 20 minutes – it’s quite annoying indeed. Perhaps the API changed but what exactly do you mean by “you have to use idBoard as well”? I see the /idBoard endpoint (https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-idboard) but using it results in an error and the /idList endpoint does not have a (documented) board id parameter