I think I have try all the solutions around here, and none of them worked for me.
The problem is that I can't move cards between list using the trello api. I have tried this ways to do it:
Number 1:
var API_KEY = '********************************';
var TOKEN = '************************************************************';
var ID_LIST = '***************************';
var payload = {
"value": ID_LIST,
"token": TOKEN,
"key": API_KEY
};
var options = {
"method": "PUT",
"payload": payload
};
// Post the payload to Trello
try {
var response = UrlFetchApp.fetch('http://api.trello.com/1/cards/[id of my card]/idList', options);
Logger.log(response);
} catch (e) {
// Log any errors
Logger.log("ERROR:\n"+e.message);
}Number 2:
function createOAthService_Trello() {
var consumerKey='*************************';
var consumerSecret = '********************************************************'
var service = OAuth1.createService("trello");
service.setAccessTokenUrl("https://trello.com/1/OAuthGetAccessToken");
service.setRequestTokenUrl("https://trello.com/1/OAuthGetRequestToken");
service.setAuthorizationUrl("https://trello.com/1/OAuthAuthorizeToken?scope=read,write");
service.setPropertyStore(PropertiesService.getScriptProperties());
service.setCallbackFunction('authCallback_Trello');
service.setConsumerKey(consumerKey);
service.setConsumerSecret(consumerSecret);
return service;
}
function checkServiceAccess(){
var service = createOAthService_Trello();
var emailAddress ='*****@********.com';
if(service.hasAccess()){
return service;
}
else {
var authorizationUrl = service.authorize();
MailApp.sendEmail(emailAddress, 'Google Script App Needs Authorization (Trello)', 'Please visit the following URL and then re-run the script: ' + authorizationUrl);
Logger.log('Please visit the following URL and then re-run the script: ' + authorizationUrl);
}
}
function moveCard(){
var service = checkServiceAccess();
var url = 'http://api.trello.com/1/cards/[myCardId]/idList?value=[newListId]&token=[myToken]&cards=open&lists=open'
var options = {"method" : "put"};
var raw= service.fetch(url, options);
Logger.log(raw);
}This two pieces of code doesn't crash. But they don't move any card, and only return a Log with the ID of the list where they are placed.
I have checked a thousand of times for the id's to be correct, so that can't be the problem. It doesn't seem to be a problem with the PUT request, because I can Update descriptions, titles,... But with the DELETE request,it fires a "Unexpected exception". Maybe they are related.
Also, I have tried to insert this on my code:
<html>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="https://trello.com/1/client.js?key=*****************************"></script>
</html>
//eval(UrlFetchApp.fetch('https://trello.com/1/client.js?key=************************').getContentText());
var success = function(successMsg) {
asyncOutput(successMsg);
};
var error = function(errorMsg) {
asyncOutput(errorMsg);
};
Logger.log(Trello.get('/member/me/boards', success, error));But it crash because it can't find the Trello global variable. I'm really desperate, any help will be apreciated . Thank you for your time! 