I want to use Trello API to execute on google-apps-script
.
but google-apps-script
does not support ES6 promise.
JS
var url = "https://api.trello.com/1/cards/{idCard}/customField/{idCustomField}/item?token={yourToken}&key={yourKey}";
var data = {value: { number: "42" }};
fetch(url, { body: JSON.stringify(data), method: 'PUT', headers: {'content-type': 'application/json'}})
.then((resp) => resp.json())
.then((data) => console.log(JSON.stringify(data, null, 2)))
.catch((err) => console.log(JSON.stringify(err, null, 2)))
You want to convert the following script to Google Apps Script.
var url = "https://api.trello.com/1/cards/{idCard}/customField/{idCustomField}/item?token={yourToken}&key={yourKey}";
var data = {value: { number: "42" }};
fetch(url, { body: JSON.stringify(data), method: 'PUT', headers: {'content-type': 'application/json'}})
.then((resp) => resp.json())
.then((data) => console.log(JSON.stringify(data, null, 2)))
.catch((err) => console.log(JSON.stringify(err, null, 2)))
Your script works fine.
If my understanding is correct, how about this modification?
var url = "https://api.trello.com/1/cards/{idCard}/customField/{idCustomField}/item?token={yourToken}&key={yourKey}";
var data = {value: { text: "42" }}; // <--- Modified
var params = {
method: 'PUT',
contentType: 'application/json',
payload: JSON.stringify(data)
};
var res = UrlFetchApp.fetch(url, params);
Logger.log(res.getContentText())
url
with your parameters.{ "value": { "text": "Hello, world!" } }
.{ "value": { "number": "42" } }
.If this didn't work, I apologize.