API bug, position of card not working

Hey there :slight_smile:

I spotted a bug in the api when creating cards, where the position field seems ignored

Reproducability:

import requests

url = “https://api.trello.com/1/cards

querystring = {“pos”:“5”, “name”:“paul”, “idList”:“5e03aef826440779352a3be4”, “key”: “key”, “token”: “token”}

response = requests.request(“POST”, url, params=querystring)

print(response.text)


This will always create and item at the top of the list --> the position field seems ignored


Returned Json

{“id”:“5e04032c8e2ff91d36303cef”,“badges”:{“attachmentsByType”:{“trello”:{“board”:0,“card”:0}},“location”:false,“votes”:0,“viewingMemberVoted”:false,“subscribed”:false,“fogbugz”:"",“checkItems”:0,“checkItemsChecked”:0,“comments”:0,“attachments”:0,“description”:false,“due”:null,“dueComplete”:false},“attachments”:[],“checkItemStates”:[],“closed”:false,“dueComplete”:false,“dateLastActivity”:“2019-12-26T00:47:40.071Z”,“desc”:"",“descData”:{“emoji”:{}},“due”:null,“dueReminder”:null,“email”:null,“idBoard”:“5e03aef826440779352a3be2”,“idChecklists”:[],“stickers”:[],“idList”:“5e03aef826440779352a3be4”,“idMembers”:[],“idMembersVoted”:[],“idShort”:234,“idAttachmentCover”:null,“labels”:[],“idLabels”:[],“manualCoverAttachment”:false,“name”:“paul”,“pos”:5,“shortLink”:“oPmFx1RF”,“shortUrl”:“https://trello.com/c/oPmFx1RF",“subscribed”:false,“url”:“https://trello.com/c/oPmFx1RF/234-paul”,“cover”:{“idAttachment”:null,“color”:null,“idUploadedBackground”:null,“size”:“normal”,“brightness”:“light”},“isTemplate”:false,"limits”:{}}

Thanks,

Paul

Hi Paul,

I’m relatively new to the Trello API, so this may not be useful, but I believe that the position field is relative to the position field of other cards in the list.

So if you want to position a card as the fifth card in a list you will want to get the position of the existing 4th and 5th card and make the position of the new card the 4th position + (5th position - 4th position)/2 … something like that.

This works for me when moving cards in my app to new positions between existing cards.

Damian

1 Like

Welcome Paul!

@dmehers is correct, the pos field is relative to the pos field of the other cards in the list. As you can see in the JSON response you shared, the pos is correctly set to 5:

“paul”,“pos”:5,“shortLink”:“oPmFx1RF”,

My guess is that all of the other cards in the list have pos values greater than 5.

1 Like