Trello API:如何从Google Apps脚本(GAS)发布卡片 [英] Trello API: How to POST a Card from Google Apps Script (GAS)

查看:92
本文介绍了Trello API:如何从Google Apps脚本(GAS)发布卡片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Apps脚本有一个能够在Trello中创建卡片的 UrlFetchApp 方法。

Google Apps Script has a UrlFetchApp method capable of creating a card in Trello.

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

How can it be used to create/modify cards in trello?

推荐答案

使用 sendHttpPost 示例对于 UrlFetchApp

Using the sendHttpPost example from the docs for UrlFetchApp and the docs for the Trello API, I came up with this:

 // 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。

Disclaimer: I haven't tested this. I've never written a Google App script or used the Trello API.

这篇关于Trello API:如何从Google Apps脚本(GAS)发布卡片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆