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
(PureBasic) Trello Create New BoardCreate a new board. For more information, see https://developers.trello.com/reference#boardsid
IncludeFile "CkRest.pb" IncludeFile "CkJsonObject.pb" IncludeFile "CkOAuth1.pb" Procedure 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. jsonToken.i = CkJsonObject::ckCreate() If jsonToken.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkJsonObject::ckLoadFile(jsonToken,"qa_data/tokens/trello.json") oauth1.i = CkOAuth1::ckCreate() If oauth1.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkOAuth1::setCkConsumerKey(oauth1, "TRELLO_CONSUMER_KEY") CkOAuth1::setCkConsumerSecret(oauth1, "TRELLO_CONSUMER_SECRET") CkOAuth1::setCkToken(oauth1, CkJsonObject::ckStringOf(jsonToken,"oauth_token")) CkOAuth1::setCkTokenSecret(oauth1, CkJsonObject::ckStringOf(jsonToken,"oauth_token_secret")) rest.i = CkRest::ckCreate() If rest.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; 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.i = 1 success = CkRest::ckConnect(rest,"api.trello.com",443,1,bAutoReconnect) If success <> 1 Debug CkRest::ckLastErrorText(rest) CkJsonObject::ckDispose(jsonToken) CkOAuth1::ckDispose(oauth1) CkRest::ckDispose(rest) ProcedureReturn EndIf CkRest::ckSetAuthOAuth1(rest,oauth1,0) CkRest::ckAddQueryParam(rest,"name","Football & Rugby") CkRest::ckAddQueryParam(rest,"defaultLabels","true") CkRest::ckAddQueryParam(rest,"defaultLists","true") CkRest::ckAddQueryParam(rest,"keepFromSource","none") CkRest::ckAddQueryParam(rest,"prefs_permissionLevel","private") CkRest::ckAddQueryParam(rest,"prefs_voting","disabled") CkRest::ckAddQueryParam(rest,"prefs_comments","members") CkRest::ckAddQueryParam(rest,"prefs_invitations","members") CkRest::ckAddQueryParam(rest,"prefs_selfJoin","true") CkRest::ckAddQueryParam(rest,"prefs_cardCovers","true") CkRest::ckAddQueryParam(rest,"prefs_background","blue") CkRest::ckAddQueryParam(rest,"prefs_cardAging","regular") CkRest::ckAddHeader(rest,"Accept","application/json") responseBody.s = CkRest::ckFullRequestFormUrlEncoded(rest,"POST","/1/boards") If CkRest::ckLastMethodSuccess(rest) <> 1 Debug CkRest::ckLastErrorText(rest) CkJsonObject::ckDispose(jsonToken) CkOAuth1::ckDispose(oauth1) CkRest::ckDispose(rest) ProcedureReturn EndIf ; We should expect a 200 response if successful. If CkRest::ckResponseStatusCode(rest) <> 200 Debug "Request Header: " Debug CkRest::ckLastRequestHeader(rest) Debug "----" Debug "Response StatusCode = " + Str(CkRest::ckResponseStatusCode(rest)) Debug "Response StatusLine: " + CkRest::ckResponseStatusText(rest) Debug "Response Header:" Debug CkRest::ckResponseHeader(rest) Debug responseBody CkJsonObject::ckDispose(jsonToken) CkOAuth1::ckDispose(oauth1) CkRest::ckDispose(rest) ProcedureReturn EndIf json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoad(json,responseBody) CkJsonObject::setCkEmitCompact(json, 0) Debug CkJsonObject::ckEmit(json) Debug "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.s name.s desc.s descData.s closed.i idOrganization.s pinned.i url.s shortUrl.s prefsPermissionLevel.s prefsVoting.s prefsComments.s prefsInvitations.s prefsSelfJoin.i prefsCardCovers.i prefsCardAging.s prefsCalendarFeedEnabled.i prefsBackground.s prefsBackgroundImage.s prefsBackgroundImageScaled.s prefsBackgroundTile.i prefsBackgroundBrightness.s prefsBackgroundColor.s prefsBackgroundBottomColor.s prefsBackgroundTopColor.s prefsCanBePublic.i prefsCanBeEnterprise.i prefsCanBeOrg.i prefsCanBePrivate.i prefsCanInvite.i labelNamesGreen.s labelNamesYellow.s labelNamesOrange.s labelNamesRed.s labelNamesPurple.s labelNamesBlue.s labelNamesSky.s labelNamesLime.s labelNamesPink.s labelNamesBlack.s id = CkJsonObject::ckStringOf(json,"id") name = CkJsonObject::ckStringOf(json,"name") desc = CkJsonObject::ckStringOf(json,"desc") descData = CkJsonObject::ckStringOf(json,"descData") closed = CkJsonObject::ckBoolOf(json,"closed") idOrganization = CkJsonObject::ckStringOf(json,"idOrganization") pinned = CkJsonObject::ckBoolOf(json,"pinned") url = CkJsonObject::ckStringOf(json,"url") shortUrl = CkJsonObject::ckStringOf(json,"shortUrl") prefsPermissionLevel = CkJsonObject::ckStringOf(json,"prefs.permissionLevel") prefsVoting = CkJsonObject::ckStringOf(json,"prefs.voting") prefsComments = CkJsonObject::ckStringOf(json,"prefs.comments") prefsInvitations = CkJsonObject::ckStringOf(json,"prefs.invitations") prefsSelfJoin = CkJsonObject::ckBoolOf(json,"prefs.selfJoin") prefsCardCovers = CkJsonObject::ckBoolOf(json,"prefs.cardCovers") prefsCardAging = CkJsonObject::ckStringOf(json,"prefs.cardAging") prefsCalendarFeedEnabled = CkJsonObject::ckBoolOf(json,"prefs.calendarFeedEnabled") prefsBackground = CkJsonObject::ckStringOf(json,"prefs.background") prefsBackgroundImage = CkJsonObject::ckStringOf(json,"prefs.backgroundImage") prefsBackgroundImageScaled = CkJsonObject::ckStringOf(json,"prefs.backgroundImageScaled") prefsBackgroundTile = CkJsonObject::ckBoolOf(json,"prefs.backgroundTile") prefsBackgroundBrightness = CkJsonObject::ckStringOf(json,"prefs.backgroundBrightness") prefsBackgroundColor = CkJsonObject::ckStringOf(json,"prefs.backgroundColor") prefsBackgroundBottomColor = CkJsonObject::ckStringOf(json,"prefs.backgroundBottomColor") prefsBackgroundTopColor = CkJsonObject::ckStringOf(json,"prefs.backgroundTopColor") prefsCanBePublic = CkJsonObject::ckBoolOf(json,"prefs.canBePublic") prefsCanBeEnterprise = CkJsonObject::ckBoolOf(json,"prefs.canBeEnterprise") prefsCanBeOrg = CkJsonObject::ckBoolOf(json,"prefs.canBeOrg") prefsCanBePrivate = CkJsonObject::ckBoolOf(json,"prefs.canBePrivate") prefsCanInvite = CkJsonObject::ckBoolOf(json,"prefs.canInvite") labelNamesGreen = CkJsonObject::ckStringOf(json,"labelNames.green") labelNamesYellow = CkJsonObject::ckStringOf(json,"labelNames.yellow") labelNamesOrange = CkJsonObject::ckStringOf(json,"labelNames.orange") labelNamesRed = CkJsonObject::ckStringOf(json,"labelNames.red") labelNamesPurple = CkJsonObject::ckStringOf(json,"labelNames.purple") labelNamesBlue = CkJsonObject::ckStringOf(json,"labelNames.blue") labelNamesSky = CkJsonObject::ckStringOf(json,"labelNames.sky") labelNamesLime = CkJsonObject::ckStringOf(json,"labelNames.lime") labelNamesPink = CkJsonObject::ckStringOf(json,"labelNames.pink") labelNamesBlack = CkJsonObject::ckStringOf(json,"labelNames.black") CkJsonObject::ckDispose(jsonToken) CkOAuth1::ckDispose(oauth1) CkRest::ckDispose(rest) CkJsonObject::ckDispose(json) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.