React Native
React Native
Trello Create New Board
See more Trello Examples
Create a new board.For more information, see https://developers.trello.com/reference#boardsid
Chilkat React Native Downloads
import { JsonObject, OAuth1, Rest } from '@chilkat/react-native'
async function chilkatExample() {
// 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.
const jsonToken = new JsonObject();
jsonToken.loadFile('qa_data/tokens/trello.json');
const oauth1 = new OAuth1();
oauth1.consumerKey = 'TRELLO_CONSUMER_KEY';
oauth1.consumerSecret = 'TRELLO_CONSUMER_SECRET';
oauth1.token = jsonToken.stringOf('oauth_token');
oauth1.tokenSecret = jsonToken.stringOf('oauth_token_secret');
const 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.
const bAutoReconnect = true;
try {
await rest.connectAsync('api.trello.com', 443, true, bAutoReconnect);
} catch {
console.log(rest.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');
let responseBody: string;
try {
responseBody = await rest.fullRequestFormUrlEncodedAsync('POST', '/1/boards');
} catch {
console.log(rest.lastErrorText);
return;
}
// We should expect a 200 response if successful.
if (rest.responseStatusCode !== 200) {
console.log('Request Header: ');
console.log(rest.lastRequestHeader);
console.log('----');
console.log(`Response StatusCode = ${rest.responseStatusCode}`);
console.log(`Response StatusLine: ${rest.responseStatusText}`);
console.log('Response Header:');
console.log(rest.responseHeader);
console.log(responseBody);
return;
}
const json = new JsonObject();
json.load(responseBody);
json.emitCompact = false;
console.log(json.emit());
console.log('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": {}
// }
const id = json.stringOf('id');
const name = json.stringOf('name');
const desc = json.stringOf('desc');
const descData = json.stringOf('descData');
const idOrganization = json.stringOf('idOrganization');
const url = json.stringOf('url');
const shortUrl = json.stringOf('shortUrl');
const prefsPermissionLevel = json.stringOf('prefs.permissionLevel');
const prefsVoting = json.stringOf('prefs.voting');
const prefsComments = json.stringOf('prefs.comments');
const prefsInvitations = json.stringOf('prefs.invitations');
const prefsCardAging = json.stringOf('prefs.cardAging');
const prefsBackground = json.stringOf('prefs.background');
const prefsBackgroundImage = json.stringOf('prefs.backgroundImage');
const prefsBackgroundImageScaled = json.stringOf('prefs.backgroundImageScaled');
const prefsBackgroundBrightness = json.stringOf('prefs.backgroundBrightness');
const prefsBackgroundColor = json.stringOf('prefs.backgroundColor');
const prefsBackgroundBottomColor = json.stringOf('prefs.backgroundBottomColor');
const prefsBackgroundTopColor = json.stringOf('prefs.backgroundTopColor');
const labelNamesGreen = json.stringOf('labelNames.green');
const labelNamesYellow = json.stringOf('labelNames.yellow');
const labelNamesOrange = json.stringOf('labelNames.orange');
const labelNamesRed = json.stringOf('labelNames.red');
const labelNamesPurple = json.stringOf('labelNames.purple');
const labelNamesBlue = json.stringOf('labelNames.blue');
const labelNamesSky = json.stringOf('labelNames.sky');
const labelNamesLime = json.stringOf('labelNames.lime');
const labelNamesPink = json.stringOf('labelNames.pink');
const labelNamesBlack = json.stringOf('labelNames.black');
}