简体   繁体   English

如何使用Trello REST API将卡移动到新列表?

[英]How Do I Move a Card to a New List Using Trello REST API?

I'm using Python to interact with Trello via its REST api. 我正在使用Python通过REST API与Trello进行交互。 I can GET from Trello fine. 我可以从Trello获得。 However, I want to move a card to a different list, but I can't get the request to stick. 但是,我想将卡片移到其他列表,但无法粘贴请求。

My url is: https://api.trello.com/1/cards/[card_id]/[list_id]?key=[api_key]&token=[token] 我的网址是: https://api.trello.com/1/cards/[card_id]/[list_id]?key=[api_key]&token=[token] : https://api.trello.com/1/cards/[card_id]/[list_id]?key=[api_key]&token=[token] /[ https://api.trello.com/1/cards/[card_id]/[list_id]?key=[api_key]&token=[token]

I've tried calling it like this: 我试过这样称呼它:

import requests
requests.put(url)

and this 和这个

import requests
requests.put(url, {"method": "put"})

and

from urllib.requests import Request
Request(url, method="PUT")

But I get a 404 error for the first two and nothing for the third. 但是前两个我收到404错误,而第三个我什么也没有。 I'm sure I'm doing something wrong, but I'm not sure what. 我确定我做错了什么,但是不确定。 Do you know? 你知道吗?

After hunting around the code from the python trello api pip install package ( https://pythonhosted.org/trello/index.html ), it seems like I have to do it like this: 在从python trello api pip安装包( https://pythonhosted.org/trello/index.html )寻找代码之后,似乎我必须这样做:

 import requests
 requests.put(https://api.trello.com/1/cards/[card_id], 
              params=dict(key=self._key, token=self._token), 
              data=dict(idList=listID))

Note that to move across boards, you need to provide the board ID as well: 请注意,要跨板移动,还需要提供板ID:

 requests.put(https://api.trello.com/1/cards/[card_id], 
              params=dict(key=self._key, token=self._token), 
              data=dict(idList=listID, idBoard=boardID))

This works for me, hope it does for you too! 这对我有用,希望对您也有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM