2013-08-13 5 views

ответ

11

Используя sendHttpPost пример из docs для UrlFetchApp и docs 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 или не использовал API Trello.

+0

приятно видеть, как вы пришли на помощь. Мне нужно включить приложение и токен, любую идею о том, как их включить? –

+0

@AperezC Я обновил его до того, что, как я думаю, должен работать. Трудно сказать, хотя сказать; их документы оставляют желать лучшего. –

+1

Спасибо! Он работал, я редактировался в соответствии с изменениями, которые я сделал, но кредит полностью у вас. –

Смежные вопросы