Sample code for 30+ languages & platforms
Rust

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 Rust Downloads

Rust

// 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.
let json_token = chilkat::JsonObject::new();
let _ = json_token.load_file("qa_data/tokens/trello.json").is_ok();

let oauth1 = chilkat::OAuth1::new();
oauth1.set_consumer_key("TRELLO_CONSUMER_KEY");
oauth1.set_consumer_secret("TRELLO_CONSUMER_SECRET");
oauth1.set_token(&json_token.string_of("oauth_token").unwrap_or_default());
oauth1.set_token_secret(&json_token.string_of("oauth_token_secret").unwrap_or_default());

let rest = chilkat::Rest::new();

// 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.
let b_auto_reconnect = true;
if rest.connect("api.trello.com", 443, true, b_auto_reconnect).is_err() {
    println!("{}", rest.last_error_text());
    return;
}

let _ = rest.set_auth_o_auth1(&oauth1, false);

let _ = rest.add_query_param("filter", "all");
let _ = rest.add_query_param("fields", "all");
let _ = rest.add_query_param("lists", "none");
let _ = rest.add_query_param("memberships", "normal");
let _ = rest.add_query_param("organization", "false");
let _ = rest.add_query_param("organization_fields", "name,displayName");

let _ = rest.add_header("Accept", "application/json");

let Ok(response_body) = rest.full_request_no_body("GET", "/1/members/member_id/boards") else {
    println!("{}", rest.last_error_text());
    return;
};

// We should expect a 200 response if successful.
if rest.response_status_code() != 200 {
    println!("Request Header: ");
    println!("{}", rest.last_request_header());
    println!("----");
    println!("Response StatusCode = {}", rest.response_status_code());
    println!("Response StatusLine: {}", rest.response_status_text());
    println!("Response Header:");
    println!("{}", rest.response_header());
    println!("{}", response_body);
    return;
}

let jarr = chilkat::JsonArray::new();
let _ = jarr.load(&response_body);
jarr.set_emit_compact(false);
println!("{}", jarr.emit().unwrap_or_default());
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
//       }
//     ]
//   }
// ]

let mut i: i32 = 0;
let mut j: i32 = 0;
let mut count_j: i32 = 0;

i = 0;
let count_i = jarr.size();
while i < count_i {
    let json = jarr.object_at(i).unwrap();
    let _ = json.string_of("name").unwrap_or_default();
    let _ = json.string_of("desc").unwrap_or_default();
    let _ = json.string_of("descData").unwrap_or_default();
    let _ = json.bool_of("closed");
    let _ = json.string_of("idOrganization").unwrap_or_default();
    let _ = json.string_of("limits").unwrap_or_default();
    let _ = json.string_of("pinned").unwrap_or_default();
    let _ = json.string_of("shortLink").unwrap_or_default();
    let _ = json.string_of("dateLastActivity").unwrap_or_default();
    let _ = json.string_of("datePluginDisable").unwrap_or_default();
    let _ = json.string_of("creationMethod").unwrap_or_default();
    let _ = json.string_of("ixUpdate").unwrap_or_default();
    let _ = json.string_of("id").unwrap_or_default();
    let _ = json.bool_of("starred");
    let _ = json.string_of("url").unwrap_or_default();
    let _ = json.string_of("prefs.permissionLevel").unwrap_or_default();
    let _ = json.string_of("prefs.voting").unwrap_or_default();
    let _ = json.string_of("prefs.comments").unwrap_or_default();
    let _ = json.string_of("prefs.invitations").unwrap_or_default();
    let _ = json.bool_of("prefs.selfJoin");
    let _ = json.bool_of("prefs.cardCovers");
    let _ = json.string_of("prefs.cardAging").unwrap_or_default();
    let _ = json.bool_of("prefs.calendarFeedEnabled");
    let _ = json.string_of("prefs.background").unwrap_or_default();
    let _ = json.string_of("prefs.backgroundImage").unwrap_or_default();
    let _ = json.bool_of("prefs.backgroundTile");
    let _ = json.string_of("prefs.backgroundBrightness").unwrap_or_default();
    let _ = json.string_of("prefs.backgroundBottomColor").unwrap_or_default();
    let _ = json.string_of("prefs.backgroundTopColor").unwrap_or_default();
    let _ = json.bool_of("prefs.canBePublic");
    let _ = json.bool_of("prefs.canBeEnterprise");
    let _ = json.bool_of("prefs.canBeOrg");
    let _ = json.bool_of("prefs.canBePrivate");
    let _ = json.bool_of("prefs.canInvite");
    let _ = json.bool_of("subscribed");
    let _ = json.string_of("labelNames.green").unwrap_or_default();
    let _ = json.string_of("labelNames.yellow").unwrap_or_default();
    let _ = json.string_of("labelNames.orange").unwrap_or_default();
    let _ = json.string_of("labelNames.red").unwrap_or_default();
    let _ = json.string_of("labelNames.purple").unwrap_or_default();
    let _ = json.string_of("labelNames.blue").unwrap_or_default();
    let _ = json.string_of("labelNames.sky").unwrap_or_default();
    let _ = json.string_of("labelNames.lime").unwrap_or_default();
    let _ = json.string_of("labelNames.pink").unwrap_or_default();
    let _ = json.string_of("labelNames.black").unwrap_or_default();
    let _ = json.string_of("dateLastView").unwrap_or_default();
    let _ = json.string_of("shortUrl").unwrap_or_default();
    let _ = json.string_of("prefs.backgroundImageScaled").unwrap_or_default();
    let _ = json.string_of("prefs.backgroundColor").unwrap_or_default();
    j = 0;
    count_j = json.size_of_array("powerUps");
    while j < count_j {
        json.set_j(j);
        // ...
        j = j + 1;
    }

    j = 0;
    count_j = json.size_of_array("idTags");
    while j < count_j {
        json.set_j(j);
        // ...
        j = j + 1;
    }

    j = 0;
    count_j = json.size_of_array("prefs.backgroundImageScaled");
    while j < count_j {
        json.set_j(j);
        let _ = json.int_of("prefs.backgroundImageScaled[j].width");
        let _ = json.int_of("prefs.backgroundImageScaled[j].height");
        let _ = json.string_of("prefs.backgroundImageScaled[j].url").unwrap_or_default();
        j = j + 1;
    }

    j = 0;
    count_j = json.size_of_array("memberships");
    while j < count_j {
        json.set_j(j);
        let _ = json.string_of("memberships[j].id").unwrap_or_default();
        let _ = json.string_of("memberships[j].idMember").unwrap_or_default();
        let _ = json.string_of("memberships[j].memberType").unwrap_or_default();
        let _ = json.bool_of("memberships[j].unconfirmed");
        let _ = json.bool_of("memberships[j].deactivated");
        j = j + 1;
    }

    i = i + 1;
}