Dart
Dart
Trello Create New Board
See more Trello Examples
Create a new board.For more information, see https://developers.trello.com/reference#boardsid
Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// curl --request POST \
// --url 'https://api.trello.com/1/boards?name=name&defaultLabels=true&defaultLists=true&keepFromSource=none&prefs_permissionLevel=private
// &prefs_voting=disabled&prefs_comments=members&prefs_invitations=members&prefs_selfJoin=true&prefs_cardCovers=true&prefs_background=blue&prefs_cardAging=regular'
// First get our previously obtained access token.
final jsonToken = CkJsonObject();
jsonToken.loadFile('qa_data/tokens/trello.json');
final oauth1 = CkOAuth1();
oauth1.consumerKey = 'TRELLO_CONSUMER_KEY';
oauth1.consumerSecret = 'TRELLO_CONSUMER_SECRET';
oauth1.token = jsonToken.stringOf('oauth_token');
oauth1.tokenSecret = jsonToken.stringOf('oauth_token_secret');
final rest = CkRest();
// 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.
final bAutoReconnect = true;
try {
rest.connect('api.trello.com', 443, true, bAutoReconnect);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
rest.setAuthOAuth1(oauth1, false);
rest.addQueryParam('name', 'Football & Rugby');
rest.addQueryParam('defaultLabels', 'true');
rest.addQueryParam('defaultLists', 'true');
rest.addQueryParam('keepFromSource', 'none');
rest.addQueryParam('prefs_permissionLevel', 'private');
rest.addQueryParam('prefs_voting', 'disabled');
rest.addQueryParam('prefs_comments', 'members');
rest.addQueryParam('prefs_invitations', 'members');
rest.addQueryParam('prefs_selfJoin', 'true');
rest.addQueryParam('prefs_cardCovers', 'true');
rest.addQueryParam('prefs_background', 'blue');
rest.addQueryParam('prefs_cardAging', 'regular');
rest.addHeader('Accept', 'application/json');
final String responseBody;
try {
responseBody = rest.fullRequestFormUrlEncoded('POST', '/1/boards');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// We should expect a 200 response if successful.
if (rest.responseStatusCode != 200) {
print('Request Header: ');
print(rest.lastRequestHeader);
print('----');
print('Response StatusCode = ${rest.responseStatusCode}');
print('Response StatusLine: ${rest.responseStatusText}');
print('Response Header:');
print(rest.responseHeader);
print(responseBody);
return;
}
final json = CkJsonObject();
json.load(responseBody);
json.emitCompact = false;
print(json.emit());
print('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
// {
// "id": "5cc606a1e2441a8a8fe3dc48",
// "name": "Football",
// "desc": "",
// "descData": null,
// "closed": false,
// "idOrganization": null,
// "pinned": false,
// "url": "https://trello.com/b/eadpS1Pe/football",
// "shortUrl": "https://trello.com/b/eadpS1Pe",
// "prefs": {
// "permissionLevel": "private",
// "voting": "disabled",
// "comments": "members",
// "invitations": "members",
// "selfJoin": true,
// "cardCovers": true,
// "cardAging": "regular",
// "calendarFeedEnabled": false,
// "background": "blue",
// "backgroundImage": null,
// "backgroundImageScaled": null,
// "backgroundTile": false,
// "backgroundBrightness": "dark",
// "backgroundColor": "#0079BF",
// "backgroundBottomColor": "#0079BF",
// "backgroundTopColor": "#0079BF",
// "canBePublic": true,
// "canBeEnterprise": true,
// "canBeOrg": true,
// "canBePrivate": true,
// "canInvite": true
// },
// "labelNames": {
// "green": "",
// "yellow": "",
// "orange": "",
// "red": "",
// "purple": "",
// "blue": "",
// "sky": "",
// "lime": "",
// "pink": "",
// "black": ""
// },
// "limits": {}
// }
final id = json.stringOf('id');
final name = json.stringOf('name');
final desc = json.stringOf('desc');
final descData = json.stringOf('descData');
final idOrganization = json.stringOf('idOrganization');
final url = json.stringOf('url');
final shortUrl = json.stringOf('shortUrl');
final prefsPermissionLevel = json.stringOf('prefs.permissionLevel');
final prefsVoting = json.stringOf('prefs.voting');
final prefsComments = json.stringOf('prefs.comments');
final prefsInvitations = json.stringOf('prefs.invitations');
final prefsCardAging = json.stringOf('prefs.cardAging');
final prefsBackground = json.stringOf('prefs.background');
final prefsBackgroundImage = json.stringOf('prefs.backgroundImage');
final prefsBackgroundImageScaled = json.stringOf('prefs.backgroundImageScaled');
final prefsBackgroundBrightness = json.stringOf('prefs.backgroundBrightness');
final prefsBackgroundColor = json.stringOf('prefs.backgroundColor');
final prefsBackgroundBottomColor = json.stringOf('prefs.backgroundBottomColor');
final prefsBackgroundTopColor = json.stringOf('prefs.backgroundTopColor');
final labelNamesGreen = json.stringOf('labelNames.green');
final labelNamesYellow = json.stringOf('labelNames.yellow');
final labelNamesOrange = json.stringOf('labelNames.orange');
final labelNamesRed = json.stringOf('labelNames.red');
final labelNamesPurple = json.stringOf('labelNames.purple');
final labelNamesBlue = json.stringOf('labelNames.blue');
final labelNamesSky = json.stringOf('labelNames.sky');
final labelNamesLime = json.stringOf('labelNames.lime');
final labelNamesPink = json.stringOf('labelNames.pink');
final labelNamesBlack = json.stringOf('labelNames.black');
}