5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

TrelloAPIを使ってラベルの色とタイトルを一括変更するためのGoogleAppsScriptコード

Last updated at Posted at 2019-12-11

Trelloのラベルの色とタイトルを変えたかったが
30個くらいあって面倒だったから一気に更新するために書いたスクリプト。

gas_sample.js
API_KEY = 'hogehoge'
API_TOKEN = 'fugafuga'
BOARD_ID = 'piyopiyo'


function getLabels(){
  var url = "https://trello.com/1/boards/" + BOARD_ID + "/labels?fields=name&key=" + API_KEY + "&token=" + API_TOKEN;
  var res = UrlFetchApp.fetch(url, {'method':'get'});
  var json = JSON.parse(res.getContentText("UTF-8"));
  
  return json
}

function putLabels(){
  var labels = getLabels()
  var len = labels.length
  
  for(var i = 0; i < len; i++){
    var url = "https://trello.com/1/labels/" + labels[i].id +"?key=" + API_KEY + "&token=" + API_TOKEN
    var payload = {
      'name'       : '2019: ' + labels[i].name, //名前をちょっとだけ更新したかった
      'color'        : '' //色をnullにしたかった
    }
  
  var options = {
    'method' : 'put',
    'muteHttpExceptions' : true,
    'payload' : payload
  }
    
    Logger.log(UrlFetchApp.fetch(url, options));
  }
}
5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?