【问题标题】:Trello API: How to POST a Card from Google Apps Script (GAS)Trello API:如何从 Google Apps 脚本 (GAS) 发布卡片
【发布时间】:2021-05-25 10:02:08
【问题描述】:

Google Apps 脚本有一个UrlFetchApp 方法,可以在 Trello 中创建卡片。

如何使用它在 trello 中创建/修改卡片?

【问题讨论】:

    标签: google-apps-script


    【解决方案1】:

    docs 中的sendHttpPost 示例用于UrlFetchAppdocs for the Trello API,我想出了这个:

     // This sample sends POST payload data in the style of an HTML form, including
     // a file.
    
     function createTrelloCard() {
    
       //POST [/1/cards], Required permissions: write
       var payload = {"name":"apiUploadedCard", //(required) Valid Values: a string with a length from 1 to 16384
                      "desc":"description", //(optional)Valid Values: a string with a length from 0 to 16384
                      "pos":"top", //(optional) Default: bottom Valid Values: A position. top, bottom, or a positive number.
                      "due": "", //(required) Valid Values: A date, or null
                      "idList":"52017776e823fa1d51000819", //(required)Valid Values: id of the list that the card should be added to
                      //"labels": ,//(optional)
                      //"idMembers": ,//(optional)Valid Values: A comma-separated list of objectIds, 24-character hex strings
                      //"idCardSource": ,//(optional)Valid Values: The id of the card to copy into a new card.
                      //"keepFromSource": ,//(optional)Default: all Valid Values: Properties of the card to copy over from the source.
                     };
    
       // Because payload is a JavaScript object, it will be interpreted as
       // an HTML form. (We do not need to specify contentType; it will
       // automatically default to either 'application/x-www-form-urlencoded'
       // or 'multipart/form-data')
       var url = 'https://api.trello.com/1/cards?key=[YourAppKey]&token=[UserToken]' //optional... -&cards=open&lists=open'-
       var options = {"method" : "post",
                      "payload" : payload};
    
       UrlFetchApp.fetch(url, options);
     }
    

    免责声明:我尚未对此进行测试。我从未编写过 Google App 脚本或使用过 Trello API。

    【讨论】:

    • 很高兴看到你来救援。我必须包含一个 appkey 和令牌,关于如何包含它们的任何想法?
    • @AperezC 我将它更新为我认为应该工作的内容。虽然很难说;他们的文档还有很多不足之处。
    • 谢谢!它起作用了,我根据我所做的修改进行了编辑,但功劳完全是你的。
    猜你喜欢
    • 2013-11-05
    • 2015-03-08
    • 2020-03-19
    • 2013-12-07
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    • 2018-10-22
    • 2021-01-10
    相关资源
    最近更新 更多