Everyone's favorite task management tool Trello has an easy-to-use user interface and is easy to use.
I investigated whether the Trello API can be easily used to link the Trello with the service I am making, so I summarized it.
To issue the API, you need to get a key and token instead of an ID and password. Get these first.
Log in to Trello.
https://trello.com/app-key
To access. Then, the key will be displayed, so make a note of it.
After that, click "Token" and the following screen will be displayed. Click "Allow".
The token will be displayed as shown below, so make a note of it.
Using this key and token, we will issue an API and issue a card to Trello.
There is a library called trello-java-wrapper on Github, so use that.
Although it is described in Gradle on the Github page, it is also in Maven, so use this.
<!-- https://mvnrepository.com/artifact/com.taskadapter/trello-java-wrapper -->
<dependency>
<groupId>com.taskadapter</groupId>
<artifactId>trello-java-wrapper</artifactId>
<version>0.13</version>
</dependency>
First, create an instance of TrelloImpl. This example uses an http client based on the Apache Http library.
Trello trelloApi = new TrelloImpl(trelloKey, trelloAccessToken, new ApacheHttpClient());
By the way, if the following error occurs,
Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/exc/InputCoercionException
I think that adding "com.fasterxml.jackson.core" in Maven will fix it.
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.10.2</version>
</dependency>
First, get a list of boards like this. If you specify the member ID as "me", you can get all your own boards.
List <Board> boards = trelloApi.getMemberBoards("me", new Argument("fields", "name"));
If the following is specified for the parameter, the board name cannot be obtained, so it must be specified.
new Argument("fields", "name")
Here's how to get the list on the board.
List <TList> lists = trelloApi.getBoardLists(boardId);
Here's how to get the cards in the list.
List <Card> cards = trelloApi.getListCards(listId);
By the way, if you code like this, you can get all the cards.
List <Board> boards = trelloApi.getMemberBoards("me", new Argument("fields", "name"));
for (Board board : boards) {
board.getName();
board.getId();
System.out.println(board.getId() + ":" + board.getName());
List <TList> lists = trelloApi.getBoardLists(board.getId());
for (TList list : lists) {
System.out.println(list.getId() + ":" + list.getName());
List <Card> cards = trelloApi.getListCards(list.getId());
for (Card card : cards) {
System.out.println(card.getId() + ":" + card.getName());
}
}
}
When issuing a card, write it like this.
Card card = new Card();
card.setName("AIUEO");
card = trelloApi.createCard(listId, card); //Registration
card.addComment("Write a comment");
card = card.update(); //update
card.delete(); //Delete
When registering a new card, create a card with createCard, specify update when updating, and delete when deleting.
trello-java-wrapper supports a single API call, so you can easily call Trello's API from Java. I can. If you're using Trello, why not give it a try?
Below, reference site https://became-free.com/how-to-use-trello-api/ http://blog.serverworks.co.jp/tech/2016/05/16/trello-api/
Recommended Posts