简体   繁体   English

如何通过Trello API发布和检索评论卡数据?

[英]How to post and retrieve comment card data through Trello API?

I'm building a web app that pushes and pulls data to/from Trello using its API. 我正在构建一个Web应用程序,该Web应用程序使用其API向Trello推入/拉出数据。

The current stack is pythonic and I use py-trello to manage most of the API calls. 当前的堆栈是pythonic ,我使用py-trello来管理大多数API调用。 But there's one endpoint leaving me perplex : post a comment on a card 但是有一个终结点让我感到困惑: 在卡片上发表评论

It seems like the current py-trello implementation does not provide a way to post a new comment and immediately retrieve its data. 似乎当前的py-trello实现无法提供发布新评论并立即检索其数据的方法。 For example, you can do it with a List : 例如,您可以使用List来实现:

def add_list(self, name):
    """Add a list to this board
    :name: name for the list
    :return: the list
    :rtype: List
    """
    obj = self.client.fetch_json(
        '/lists',
        http_method='POST',
        post_args={'name': name, 'idBoard': self.id}, )
    return List.from_json(board=self, json_obj=obj)

Trello API return the created list object as a JSON object. Trello API将创建的列表对象作为JSON对象返回。 py-trello turns this JSON into a List object. py-trello将此JSON转换为List对象。

Is there a way to do the same with Card comment? 有没有办法对卡片评论做同样的事情? Card class comes with an "add comment" feature ( code ). 卡类具有“添加注释”功能( 代码 )。

But Trello seems to return nothing... 但是Trello似乎一无所获...

>>> # Card definition
>>> card = Card(parent=trello_board, card_id=id)
>>> # Fetching card data
>>> card.fetch()
>>> # This is correctly pushed to Trello
>>> obj = card.comment('Foo, bar!')
>>> import pprint
>>> # Hoping to print a big fat JSON
>>> pp = pprint.PrettyPrinter(indent=4)
>>> pp.pprint(obj)
None

Any clue ? 有什么线索吗? Thanks alot ! 非常感谢 !

The issue was coming from py-trello current implementation. 问题来自py-trello当前的实现。 See my answer : https://github.com/sarumont/py-trello/issues/113 看到我的答案: https : //github.com/sarumont/py-trello/issues/113

Thank you folks ! 谢谢大家!

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

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