Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Delphi DLL) Trello Create New BoardCreate a new board. For more information, see https://developers.trello.com/reference#boardsid
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, OAuth1, Rest, JsonObject; ... procedure TForm1.Button1Click(Sender: TObject); var jsonToken: HCkJsonObject; success: Boolean; oauth1: HCkOAuth1; rest: HCkRest; bAutoReconnect: Boolean; responseBody: PWideChar; json: HCkJsonObject; id: PWideChar; name: PWideChar; desc: PWideChar; descData: PWideChar; closed: Boolean; idOrganization: PWideChar; pinned: Boolean; url: PWideChar; shortUrl: PWideChar; prefsPermissionLevel: PWideChar; prefsVoting: PWideChar; prefsComments: PWideChar; prefsInvitations: PWideChar; prefsSelfJoin: Boolean; prefsCardCovers: Boolean; prefsCardAging: PWideChar; prefsCalendarFeedEnabled: Boolean; prefsBackground: PWideChar; prefsBackgroundImage: PWideChar; prefsBackgroundImageScaled: PWideChar; prefsBackgroundTile: Boolean; prefsBackgroundBrightness: PWideChar; prefsBackgroundColor: PWideChar; prefsBackgroundBottomColor: PWideChar; prefsBackgroundTopColor: PWideChar; prefsCanBePublic: Boolean; prefsCanBeEnterprise: Boolean; prefsCanBeOrg: Boolean; prefsCanBePrivate: Boolean; prefsCanInvite: Boolean; labelNamesGreen: PWideChar; labelNamesYellow: PWideChar; labelNamesOrange: PWideChar; labelNamesRed: PWideChar; labelNamesPurple: PWideChar; labelNamesBlue: PWideChar; labelNamesSky: PWideChar; labelNamesLime: PWideChar; labelNamesPink: PWideChar; labelNamesBlack: PWideChar; begin // 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. jsonToken := CkJsonObject_Create(); success := CkJsonObject_LoadFile(jsonToken,'qa_data/tokens/trello.json'); oauth1 := CkOAuth1_Create(); CkOAuth1_putConsumerKey(oauth1,'TRELLO_CONSUMER_KEY'); CkOAuth1_putConsumerSecret(oauth1,'TRELLO_CONSUMER_SECRET'); CkOAuth1_putToken(oauth1,CkJsonObject__stringOf(jsonToken,'oauth_token')); CkOAuth1_putTokenSecret(oauth1,CkJsonObject__stringOf(jsonToken,'oauth_token_secret')); rest := CkRest_Create(); // 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. bAutoReconnect := True; success := CkRest_Connect(rest,'api.trello.com',443,True,bAutoReconnect); if (success <> True) then begin Memo1.Lines.Add(CkRest__lastErrorText(rest)); Exit; end; CkRest_SetAuthOAuth1(rest,oauth1,False); CkRest_AddQueryParam(rest,'name','Football & Rugby'); CkRest_AddQueryParam(rest,'defaultLabels','true'); CkRest_AddQueryParam(rest,'defaultLists','true'); CkRest_AddQueryParam(rest,'keepFromSource','none'); CkRest_AddQueryParam(rest,'prefs_permissionLevel','private'); CkRest_AddQueryParam(rest,'prefs_voting','disabled'); CkRest_AddQueryParam(rest,'prefs_comments','members'); CkRest_AddQueryParam(rest,'prefs_invitations','members'); CkRest_AddQueryParam(rest,'prefs_selfJoin','true'); CkRest_AddQueryParam(rest,'prefs_cardCovers','true'); CkRest_AddQueryParam(rest,'prefs_background','blue'); CkRest_AddQueryParam(rest,'prefs_cardAging','regular'); CkRest_AddHeader(rest,'Accept','application/json'); responseBody := CkRest__fullRequestFormUrlEncoded(rest,'POST','/1/boards'); if (CkRest_getLastMethodSuccess(rest) <> True) then begin Memo1.Lines.Add(CkRest__lastErrorText(rest)); Exit; end; // We should expect a 200 response if successful. if (CkRest_getResponseStatusCode(rest) <> 200) then begin Memo1.Lines.Add('Request Header: '); Memo1.Lines.Add(CkRest__lastRequestHeader(rest)); Memo1.Lines.Add('----'); Memo1.Lines.Add('Response StatusCode = ' + IntToStr(CkRest_getResponseStatusCode(rest))); Memo1.Lines.Add('Response StatusLine: ' + CkRest__responseStatusText(rest)); Memo1.Lines.Add('Response Header:'); Memo1.Lines.Add(CkRest__responseHeader(rest)); Memo1.Lines.Add(responseBody); Exit; end; json := CkJsonObject_Create(); CkJsonObject_Load(json,responseBody); CkJsonObject_putEmitCompact(json,False); Memo1.Lines.Add(CkJsonObject__emit(json)); Memo1.Lines.Add('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": {} // } id := CkJsonObject__stringOf(json,'id'); name := CkJsonObject__stringOf(json,'name'); desc := CkJsonObject__stringOf(json,'desc'); descData := CkJsonObject__stringOf(json,'descData'); closed := CkJsonObject_BoolOf(json,'closed'); idOrganization := CkJsonObject__stringOf(json,'idOrganization'); pinned := CkJsonObject_BoolOf(json,'pinned'); url := CkJsonObject__stringOf(json,'url'); shortUrl := CkJsonObject__stringOf(json,'shortUrl'); prefsPermissionLevel := CkJsonObject__stringOf(json,'prefs.permissionLevel'); prefsVoting := CkJsonObject__stringOf(json,'prefs.voting'); prefsComments := CkJsonObject__stringOf(json,'prefs.comments'); prefsInvitations := CkJsonObject__stringOf(json,'prefs.invitations'); prefsSelfJoin := CkJsonObject_BoolOf(json,'prefs.selfJoin'); prefsCardCovers := CkJsonObject_BoolOf(json,'prefs.cardCovers'); prefsCardAging := CkJsonObject__stringOf(json,'prefs.cardAging'); prefsCalendarFeedEnabled := CkJsonObject_BoolOf(json,'prefs.calendarFeedEnabled'); prefsBackground := CkJsonObject__stringOf(json,'prefs.background'); prefsBackgroundImage := CkJsonObject__stringOf(json,'prefs.backgroundImage'); prefsBackgroundImageScaled := CkJsonObject__stringOf(json,'prefs.backgroundImageScaled'); prefsBackgroundTile := CkJsonObject_BoolOf(json,'prefs.backgroundTile'); prefsBackgroundBrightness := CkJsonObject__stringOf(json,'prefs.backgroundBrightness'); prefsBackgroundColor := CkJsonObject__stringOf(json,'prefs.backgroundColor'); prefsBackgroundBottomColor := CkJsonObject__stringOf(json,'prefs.backgroundBottomColor'); prefsBackgroundTopColor := CkJsonObject__stringOf(json,'prefs.backgroundTopColor'); prefsCanBePublic := CkJsonObject_BoolOf(json,'prefs.canBePublic'); prefsCanBeEnterprise := CkJsonObject_BoolOf(json,'prefs.canBeEnterprise'); prefsCanBeOrg := CkJsonObject_BoolOf(json,'prefs.canBeOrg'); prefsCanBePrivate := CkJsonObject_BoolOf(json,'prefs.canBePrivate'); prefsCanInvite := CkJsonObject_BoolOf(json,'prefs.canInvite'); labelNamesGreen := CkJsonObject__stringOf(json,'labelNames.green'); labelNamesYellow := CkJsonObject__stringOf(json,'labelNames.yellow'); labelNamesOrange := CkJsonObject__stringOf(json,'labelNames.orange'); labelNamesRed := CkJsonObject__stringOf(json,'labelNames.red'); labelNamesPurple := CkJsonObject__stringOf(json,'labelNames.purple'); labelNamesBlue := CkJsonObject__stringOf(json,'labelNames.blue'); labelNamesSky := CkJsonObject__stringOf(json,'labelNames.sky'); labelNamesLime := CkJsonObject__stringOf(json,'labelNames.lime'); labelNamesPink := CkJsonObject__stringOf(json,'labelNames.pink'); labelNamesBlack := CkJsonObject__stringOf(json,'labelNames.black'); CkJsonObject_Dispose(jsonToken); CkOAuth1_Dispose(oauth1); CkRest_Dispose(rest); CkJsonObject_Dispose(json); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.