Java
Chilkat2 Java
Trello List Member Boards
See more Trello Examples
Lists the boards that the user is a member of.For more information, see https://developers.trello.com/reference#membersidboards
Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.JsonArray;
import com.chilkatsoft.chilkat2.JsonObject;
import com.chilkatsoft.chilkat2.OAuth1;
import com.chilkatsoft.chilkat2.Rest;
public class ChilkatExample {
public static void main(String[] args) {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// curl --request GET \
// --url 'https://api.trello.com/1/members/{member_id}/boards?filter=all&fields=all&lists=none&memberships=none&organization=false&organization_fields=displayName'
// First get our previously obtained access token.
JsonObject jsonToken = new JsonObject();
jsonToken.loadFile("qa_data/tokens/trello.json");
OAuth1 oauth1 = new OAuth1();
oauth1.setConsumerKey("TRELLO_CONSUMER_KEY");
oauth1.setConsumerSecret("TRELLO_CONSUMER_SECRET");
oauth1.setToken(jsonToken.stringOf("oauth_token"));
oauth1.setTokenSecret(jsonToken.stringOf("oauth_token_secret"));
Rest rest = new Rest();
// Connect using TLS.
// A single REST object, once connected, can be used for many Trello REST API calls.
// The auto-reconnect indicates that if the already-established HTTPS connection is closed,
// then it will be automatically re-established as needed.
boolean bAutoReconnect = true;
String responseBody;
try {
rest.connect("api.trello.com", 443, true, bAutoReconnect);
rest.setAuthOAuth1(oauth1, false);
rest.addQueryParam("filter", "all");
rest.addQueryParam("fields", "all");
rest.addQueryParam("lists", "none");
rest.addQueryParam("memberships", "normal");
rest.addQueryParam("organization", "false");
rest.addQueryParam("organization_fields", "name,displayName");
rest.addHeader("Accept", "application/json");
responseBody = rest.fullRequestNoBody("GET", "/1/members/member_id/boards");
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
// We should expect a 200 response if successful.
if (rest.getResponseStatusCode() != 200) {
System.out.println("Request Header: ");
System.out.println(rest.getLastRequestHeader());
System.out.println("----");
System.out.println("Response StatusCode = " + rest.getResponseStatusCode());
System.out.println("Response StatusLine: " + rest.getResponseStatusText());
System.out.println("Response Header:");
System.out.println(rest.getResponseHeader());
System.out.println(responseBody);
return;
}
JsonArray jarr = new JsonArray();
jarr.load(responseBody);
jarr.setEmitCompact(false);
System.out.println(jarr.emit());
System.out.println("Success.");
// A sample JSON response:
// (See the parsing code below...)
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
// [
// {
// "name": "House Projects",
// "desc": "",
// "descData": null,
// "closed": false,
// "idOrganization": null,
// "limits": null,
// "pinned": null,
// "shortLink": "j1hkQKKS",
// "powerUps": [
// ],
// "dateLastActivity": null,
// "idTags": [
// ],
// "datePluginDisable": null,
// "creationMethod": null,
// "ixUpdate": null,
// "id": "5cc5fe862106bb8e05aa41e7",
// "starred": false,
// "url": "https://trello.com/b/j1hkQKKS/house-projects",
// "prefs": {
// "permissionLevel": "private",
// "voting": "disabled",
// "comments": "members",
// "invitations": "members",
// "selfJoin": false,
// "cardCovers": true,
// "cardAging": "regular",
// "calendarFeedEnabled": false,
// "background": "5cc344f6ba4cdc5f5cfc7d81",
// "backgroundImage": "https://trello-backgrounds.s3.amazonaws.com/SharedBackground/2560x1709/4418c78f2f66d26932fef88aead2aff5/photo-1555985202-12975b0235dc",
// "backgroundImageScaled": [
// {
// "width": 140,
// "height": 93,
// "url": "https://trello-backgrounds.s3.amazonaws.com/SharedBackground/140x93/0aebced0ac2d8c9c4b9231b1960d28c2/photo-1555985202-12975b0235dc.jpg"
// },
// ...
// {
// "width": 2560,
// "height": 1709,
// "url": "https://trello-backgrounds.s3.amazonaws.com/SharedBackground/2560x1709/4418c78f2f66d26932fef88aead2aff5/photo-1555985202-12975b0235dc"
// }
// ],
// "backgroundTile": false,
// "backgroundBrightness": "dark",
// "backgroundBottomColor": "#412f23",
// "backgroundTopColor": "#a99d97",
// "canBePublic": true,
// "canBeEnterprise": true,
// "canBeOrg": true,
// "canBePrivate": true,
// "canInvite": true
// },
// "subscribed": false,
// "labelNames": {
// "green": "",
// "yellow": "",
// "orange": "",
// "red": "",
// "purple": "",
// "blue": "",
// "sky": "",
// "lime": "",
// "pink": "",
// "black": ""
// },
// "dateLastView": "2019-04-28T19:28:18.159Z",
// "shortUrl": "https://trello.com/b/j1hkQKKS",
// "memberships": [
// {
// "id": "5cc5fe862106bb8e05aa41e8",
// "idMember": "5cc5c74067d5215921ca7677",
// "memberType": "admin",
// "unconfirmed": false,
// "deactivated": false
// }
// ]
// },
// {
// "name": "Vacation Planning",
// "desc": "",
// "descData": null,
// "closed": false,
// "idOrganization": null,
// "limits": null,
// "pinned": null,
// "shortLink": "QqIHvQyz",
// "powerUps": [
// ],
// "dateLastActivity": "2019-04-28T15:32:20.134Z",
// "idTags": [
// ],
// "datePluginDisable": null,
// "creationMethod": "assisted",
// "ixUpdate": null,
// "id": "5cc5c783f5b10f8717a6b3d6",
// "starred": false,
// "url": "https://trello.com/b/QqIHvQyz/vacation-planning",
// "prefs": {
// "permissionLevel": "private",
// "voting": "disabled",
// "comments": "members",
// "invitations": "members",
// "selfJoin": true,
// "cardCovers": true,
// "cardAging": "regular",
// "calendarFeedEnabled": false,
// "background": "lime",
// "backgroundImage": null,
// "backgroundImageScaled": null,
// "backgroundTile": false,
// "backgroundBrightness": "dark",
// "backgroundColor": "#4BBF6B",
// "backgroundBottomColor": "#4BBF6B",
// "backgroundTopColor": "#4BBF6B",
// "canBePublic": true,
// "canBeEnterprise": true,
// "canBeOrg": true,
// "canBePrivate": true,
// "canInvite": true
// },
// "subscribed": false,
// "labelNames": {
// "green": "",
// "yellow": "",
// "orange": "",
// "red": "",
// "purple": "",
// "blue": "",
// "sky": "",
// "lime": "",
// "pink": "",
// "black": ""
// },
// "dateLastView": "2019-04-28T19:32:21.009Z",
// "shortUrl": "https://trello.com/b/QqIHvQyz",
// "memberships": [
// {
// "id": "5cc5c783f5b10f8717a6b3d7",
// "idMember": "5cc5c74067d5215921ca7677",
// "memberType": "admin",
// "unconfirmed": false,
// "deactivated": false
// }
// ]
// }
// ]
JsonObject json = null;
String name = "";
String desc = "";
String descData = "";
boolean closed = false;
String idOrganization = "";
String limits = "";
String pinned = "";
String shortLink = "";
String dateLastActivity = "";
String datePluginDisable = "";
String creationMethod = "";
String ixUpdate = "";
String id = "";
boolean starred = false;
String url = "";
String prefsPermissionLevel = "";
String prefsVoting = "";
String prefsComments = "";
String prefsInvitations = "";
boolean prefsSelfJoin = false;
boolean prefsCardCovers = false;
String prefsCardAging = "";
boolean prefsCalendarFeedEnabled = false;
String prefsBackground = "";
String prefsBackgroundImage = "";
boolean prefsBackgroundTile = false;
String prefsBackgroundBrightness = "";
String prefsBackgroundBottomColor = "";
String prefsBackgroundTopColor = "";
boolean prefsCanBePublic = false;
boolean prefsCanBeEnterprise = false;
boolean prefsCanBeOrg = false;
boolean prefsCanBePrivate = false;
boolean prefsCanInvite = false;
boolean subscribed = false;
String labelNamesGreen = "";
String labelNamesYellow = "";
String labelNamesOrange = "";
String labelNamesRed = "";
String labelNamesPurple = "";
String labelNamesBlue = "";
String labelNamesSky = "";
String labelNamesLime = "";
String labelNamesPink = "";
String labelNamesBlack = "";
String dateLastView = "";
String shortUrl = "";
String prefsBackgroundImageScaled = "";
String prefsBackgroundColor = "";
int j = 0;
int count_j = 0;
int width = 0;
int height = 0;
String idMember = "";
String memberType = "";
boolean unconfirmed = false;
boolean deactivated = false;
int i = 0;
int count_i = jarr.getSize();
while (i < count_i) {
json = jarr.objectAt(i);
name = json.stringOf("name");
desc = json.stringOf("desc");
descData = json.stringOf("descData");
closed = json.boolOf("closed");
idOrganization = json.stringOf("idOrganization");
limits = json.stringOf("limits");
pinned = json.stringOf("pinned");
shortLink = json.stringOf("shortLink");
dateLastActivity = json.stringOf("dateLastActivity");
datePluginDisable = json.stringOf("datePluginDisable");
creationMethod = json.stringOf("creationMethod");
ixUpdate = json.stringOf("ixUpdate");
id = json.stringOf("id");
starred = json.boolOf("starred");
url = json.stringOf("url");
prefsPermissionLevel = json.stringOf("prefs.permissionLevel");
prefsVoting = json.stringOf("prefs.voting");
prefsComments = json.stringOf("prefs.comments");
prefsInvitations = json.stringOf("prefs.invitations");
prefsSelfJoin = json.boolOf("prefs.selfJoin");
prefsCardCovers = json.boolOf("prefs.cardCovers");
prefsCardAging = json.stringOf("prefs.cardAging");
prefsCalendarFeedEnabled = json.boolOf("prefs.calendarFeedEnabled");
prefsBackground = json.stringOf("prefs.background");
prefsBackgroundImage = json.stringOf("prefs.backgroundImage");
prefsBackgroundTile = json.boolOf("prefs.backgroundTile");
prefsBackgroundBrightness = json.stringOf("prefs.backgroundBrightness");
prefsBackgroundBottomColor = json.stringOf("prefs.backgroundBottomColor");
prefsBackgroundTopColor = json.stringOf("prefs.backgroundTopColor");
prefsCanBePublic = json.boolOf("prefs.canBePublic");
prefsCanBeEnterprise = json.boolOf("prefs.canBeEnterprise");
prefsCanBeOrg = json.boolOf("prefs.canBeOrg");
prefsCanBePrivate = json.boolOf("prefs.canBePrivate");
prefsCanInvite = json.boolOf("prefs.canInvite");
subscribed = json.boolOf("subscribed");
labelNamesGreen = json.stringOf("labelNames.green");
labelNamesYellow = json.stringOf("labelNames.yellow");
labelNamesOrange = json.stringOf("labelNames.orange");
labelNamesRed = json.stringOf("labelNames.red");
labelNamesPurple = json.stringOf("labelNames.purple");
labelNamesBlue = json.stringOf("labelNames.blue");
labelNamesSky = json.stringOf("labelNames.sky");
labelNamesLime = json.stringOf("labelNames.lime");
labelNamesPink = json.stringOf("labelNames.pink");
labelNamesBlack = json.stringOf("labelNames.black");
dateLastView = json.stringOf("dateLastView");
shortUrl = json.stringOf("shortUrl");
prefsBackgroundImageScaled = json.stringOf("prefs.backgroundImageScaled");
prefsBackgroundColor = json.stringOf("prefs.backgroundColor");
j = 0;
count_j = json.sizeOfArray("powerUps");
while (j < count_j) {
json.setJ(j);
// ...
j = j + 1;
}
j = 0;
count_j = json.sizeOfArray("idTags");
while (j < count_j) {
json.setJ(j);
// ...
j = j + 1;
}
j = 0;
count_j = json.sizeOfArray("prefs.backgroundImageScaled");
while (j < count_j) {
json.setJ(j);
width = json.intOf("prefs.backgroundImageScaled[j].width");
height = json.intOf("prefs.backgroundImageScaled[j].height");
url = json.stringOf("prefs.backgroundImageScaled[j].url");
j = j + 1;
}
j = 0;
count_j = json.sizeOfArray("memberships");
while (j < count_j) {
json.setJ(j);
id = json.stringOf("memberships[j].id");
idMember = json.stringOf("memberships[j].idMember");
memberType = json.stringOf("memberships[j].memberType");
unconfirmed = json.boolOf("memberships[j].unconfirmed");
deactivated = json.boolOf("memberships[j].deactivated");
j = j + 1;
}
json.close();
i = i + 1;
}
}
}