Rebelss
Rebelss

Reputation: 502

Trello API via javascript with Trello object

I'm trying to fire a put request to move a trello Card to another list without success, I can change the name and due date, but not the list.

It's a very simple code, I don't know what's wrong with my code. I believe idList value is right, I create a card in the target list and typed .json just to check the idList and this is the result :

enter image description here

so, any thoughts that may help ?

<!DOCTYPE html>
<html>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="https://api.trello.com/1/client.js?key=********************************&token=****************************************************************"></script>

<body>
  <script>
    $(document).ready(function() {
      Trello.put('/cards/5772bc30da92129b953111bd', {
        name: 'test change name 1'
      }); // works normally
      Trello.put('/cards/5772bc30da92129b953111bd', {
        due: '07/01/2016'
      }); // works normally
      Trello.put('/cards/5772bc30da92129b953111bd', {
        idList: '576eee0460bbb196ccc48d37'
      }); //doesn't work
    });
  </script>

</body>
</html>

Solution : thank you guys for try to help me, i figure out the solution.

I'm forgetting to mention that i'm sending the card to another board, so it's necessary to inform idBoard with the request :

Trello.put('/cards/5772bc30da92129b953111bd', 
  {idBoard: '576eed9a21fa5781af4edf5b'}
  {idList: '576eee0460bbb196ccc48d37'}); // works fine!

After inform the idBoard works fine, thank you again!

Upvotes: 1

Views: 1552

Answers (2)

rpadovani
rpadovani

Reputation: 7360

If you're moving the card in a list that belongs to another board, you have to change the boardId value as well.

I also suggest you to always check the value that is returned on error by Trello, it is the 4th argument of the call - you need to pass a function that will be used as callback on error!

Upvotes: 1

Rajesh Kathiriya
Rajesh Kathiriya

Reputation: 172

from API docs it seem idList value should be

id of the list the card should be moved to

check Here

in Your code should change value of

'576eee0460bbb196ccc48d37'

to the id value of list where you want to move your card.

this id value will be same for app card belong to that list

Upvotes: 0

Related Questions