【问题标题】:Add Member to Card with Trello API and Python使用 Trello API 和 Python 将成员添加到卡片
【发布时间】:2014-09-28 20:54:25
【问题描述】:

我很难使用我的 python 脚本将会员添加到卡片。我正在循环使用我要更新的卡 ID 的元组列表。我可以很好地执行 PUT 命令,但执行 POST 命令会导致错误。我对 Python 脚本比较陌生,不确定如何进一步排除故障以找出我做错了什么......请帮助。

执行 PUT 语句对我不起作用,因为它会从卡中删除任何现有成员并仅添加我指定的成员.....理想的情况是仅使用 POST 命令将成员添加到卡。

这是我正在使用的代码:

for card in cards: 
    try:
        post_url = 'https://api.trello.com/1/cards/' + card[0] + '?key=<myKey>&token=<myWriteToken>'
        opener = urllib2.build_opener(urllib2.HTTPHandler)
        request = urllib2.Request(post_url, data='idMembers=<myMemberID>')
        request.get_method = lambda: 'POST'
        url = opener.open(request)
    except urllib2.HTTPError, e: print 'ERROR occured'
        print e.code
        print e.read()

我也试过这样:

for card in cards: 
    try:
        post_url = 'https://api.trello.com/1/cards/' + card[0] + '?key=<myKey>&token=<myWriteToken>'
        opener = urllib2.build_opener(urllib2.HTTPHandler)
        query_args = {'idMembers':'<myMemberID>'}
        encoded_args = urllib.urlencode(query_args)
        request = urllib2.Request(post_url, encoded_args)
        request.get_method = lambda: 'POST'
        url = opener.open(request)
    except urllib2.HTTPError, e: print 'ERROR occured'
        print e.code
        print e.read()

【问题讨论】:

    标签: python python-2.7 urllib2 urllib trello


    【解决方案1】:

    你不想发布到/1/cards/(idCard)——这甚至不是一条有效的路线。要将成员添加到卡片,您需要 POST 到 /1/cards/(idCard)/idMembers

    【讨论】:

      猜你喜欢
      • 2017-02-01
      • 2020-01-29
      • 1970-01-01
      • 2014-10-30
      • 2014-11-30
      • 2018-05-14
      • 2018-12-31
      • 2020-05-24
      • 2017-11-01
      相关资源
      最近更新 更多