Perl
Perl
Trello Create New Board
See more Trello Examples
Create a new board.For more information, see https://developers.trello.com/reference#boardsid
Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
# 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.
my $jsonToken = Chilkat2::JsonObject->new;
my $success = $jsonToken->LoadFile('qa_data/tokens/trello.json');
my $oauth1 = Chilkat2::OAuth1->new;
$oauth1->ConsumerKey('TRELLO_CONSUMER_KEY');
$oauth1->ConsumerSecret('TRELLO_CONSUMER_SECRET');
$oauth1->Token($jsonToken->StringOf('oauth_token'));
$oauth1->TokenSecret($jsonToken->StringOf('oauth_token_secret'));
my $rest = Chilkat2::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.
my $bAutoReconnect = 1;
$success = $rest->Connect('api.trello.com', 443, 1, $bAutoReconnect);
if (!$success) {
print $rest->LastErrorText, "\n";
exit;
}
$rest->SetAuthOAuth1($oauth1, 0);
$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');
my $responseBody = $rest->FullRequestFormUrlEncoded('POST', '/1/boards');
if (!$rest->LastMethodSuccess) {
print $rest->LastErrorText, "\n";
exit;
}
# We should expect a 200 response if successful.
if ($rest->ResponseStatusCode != 200) {
print "Request Header: \n";
print $rest->LastRequestHeader, "\n";
print "----\n";
print 'Response StatusCode = ', $rest->ResponseStatusCode, "\n";
print 'Response StatusLine: ', $rest->ResponseStatusText, "\n";
print "Response Header:\n";
print $rest->ResponseHeader, "\n";
print $responseBody, "\n";
exit;
}
my $json = Chilkat2::JsonObject->new;
$json->Load($responseBody);
$json->EmitCompact(0);
print $json->Emit(), "\n";
print "Success.\n";
# 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": {}
# }
my $id = $json->StringOf('id');
my $name = $json->StringOf('name');
my $desc = $json->StringOf('desc');
my $descData = $json->StringOf('descData');
my $closed = $json->BoolOf('closed');
my $idOrganization = $json->StringOf('idOrganization');
my $pinned = $json->BoolOf('pinned');
my $url = $json->StringOf('url');
my $shortUrl = $json->StringOf('shortUrl');
my $prefsPermissionLevel = $json->StringOf('prefs.permissionLevel');
my $prefsVoting = $json->StringOf('prefs.voting');
my $prefsComments = $json->StringOf('prefs.comments');
my $prefsInvitations = $json->StringOf('prefs.invitations');
my $prefsSelfJoin = $json->BoolOf('prefs.selfJoin');
my $prefsCardCovers = $json->BoolOf('prefs.cardCovers');
my $prefsCardAging = $json->StringOf('prefs.cardAging');
my $prefsCalendarFeedEnabled = $json->BoolOf('prefs.calendarFeedEnabled');
my $prefsBackground = $json->StringOf('prefs.background');
my $prefsBackgroundImage = $json->StringOf('prefs.backgroundImage');
my $prefsBackgroundImageScaled = $json->StringOf('prefs.backgroundImageScaled');
my $prefsBackgroundTile = $json->BoolOf('prefs.backgroundTile');
my $prefsBackgroundBrightness = $json->StringOf('prefs.backgroundBrightness');
my $prefsBackgroundColor = $json->StringOf('prefs.backgroundColor');
my $prefsBackgroundBottomColor = $json->StringOf('prefs.backgroundBottomColor');
my $prefsBackgroundTopColor = $json->StringOf('prefs.backgroundTopColor');
my $prefsCanBePublic = $json->BoolOf('prefs.canBePublic');
my $prefsCanBeEnterprise = $json->BoolOf('prefs.canBeEnterprise');
my $prefsCanBeOrg = $json->BoolOf('prefs.canBeOrg');
my $prefsCanBePrivate = $json->BoolOf('prefs.canBePrivate');
my $prefsCanInvite = $json->BoolOf('prefs.canInvite');
my $labelNamesGreen = $json->StringOf('labelNames.green');
my $labelNamesYellow = $json->StringOf('labelNames.yellow');
my $labelNamesOrange = $json->StringOf('labelNames.orange');
my $labelNamesRed = $json->StringOf('labelNames.red');
my $labelNamesPurple = $json->StringOf('labelNames.purple');
my $labelNamesBlue = $json->StringOf('labelNames.blue');
my $labelNamesSky = $json->StringOf('labelNames.sky');
my $labelNamesLime = $json->StringOf('labelNames.lime');
my $labelNamesPink = $json->StringOf('labelNames.pink');
my $labelNamesBlack = $json->StringOf('labelNames.black');