Sample code for 30+ languages & platforms
SQL Server

Trello List Member Boards

See more Trello Examples

Lists the boards that the user is a member of.

For more information, see https://developers.trello.com/reference#membersidboards

Chilkat SQL Server Downloads

SQL Server
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    -- curl --request GET \
    --   --url 'https://api.trello.com/1/members/{member_id}/boards?filter=all&fields=all&lists=none&memberships=none&organization=false&organization_fields=displayName'

    -- First get our previously obtained access token.
    DECLARE @jsonToken int
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jsonToken OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OAMethod @jsonToken, 'LoadFile', @success OUT, 'qa_data/tokens/trello.json'

    DECLARE @oauth1 int
    EXEC @hr = sp_OACreate 'Chilkat.OAuth1', @oauth1 OUT

    EXEC sp_OASetProperty @oauth1, 'ConsumerKey', 'TRELLO_CONSUMER_KEY'
    EXEC sp_OASetProperty @oauth1, 'ConsumerSecret', 'TRELLO_CONSUMER_SECRET'
    EXEC sp_OAMethod @jsonToken, 'StringOf', @sTmp0 OUT, 'oauth_token'
    EXEC sp_OASetProperty @oauth1, 'Token', @sTmp0
    EXEC sp_OAMethod @jsonToken, 'StringOf', @sTmp0 OUT, 'oauth_token_secret'
    EXEC sp_OASetProperty @oauth1, 'TokenSecret', @sTmp0

    DECLARE @rest int
    EXEC @hr = sp_OACreate 'Chilkat.Rest', @rest OUT

    -- 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.
    DECLARE @bAutoReconnect int
    SELECT @bAutoReconnect = 1
    EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'api.trello.com', 443, 1, @bAutoReconnect
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @jsonToken
        EXEC @hr = sp_OADestroy @oauth1
        EXEC @hr = sp_OADestroy @rest
        RETURN
      END

    EXEC sp_OAMethod @rest, 'SetAuthOAuth1', @success OUT, @oauth1, 0

    EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'filter', 'all'
    EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'fields', 'all'
    EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'lists', 'none'
    EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'memberships', 'normal'
    EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'organization', 'false'
    EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'organization_fields', 'name,displayName'

    EXEC sp_OAMethod @rest, 'AddHeader', @success OUT, 'Accept', 'application/json'

    DECLARE @responseBody nvarchar(4000)
    EXEC sp_OAMethod @rest, 'FullRequestNoBody', @responseBody OUT, 'GET', '/1/members/member_id/boards'
    EXEC sp_OAGetProperty @rest, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 <> 1
      BEGIN
        EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @jsonToken
        EXEC @hr = sp_OADestroy @oauth1
        EXEC @hr = sp_OADestroy @rest
        RETURN
      END

    -- We should expect a 200 response if successful.
    EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT
    IF @iTmp0 <> 200
      BEGIN

        PRINT 'Request Header: '
        EXEC sp_OAGetProperty @rest, 'LastRequestHeader', @sTmp0 OUT
        PRINT @sTmp0

        PRINT '----'

        EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT
        PRINT 'Response StatusCode = ' + @iTmp0

        EXEC sp_OAGetProperty @rest, 'ResponseStatusText', @sTmp0 OUT
        PRINT 'Response StatusLine: ' + @sTmp0

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @rest, 'ResponseHeader', @sTmp0 OUT
        PRINT @sTmp0

        PRINT @responseBody
        EXEC @hr = sp_OADestroy @jsonToken
        EXEC @hr = sp_OADestroy @oauth1
        EXEC @hr = sp_OADestroy @rest
        RETURN
      END

    DECLARE @jarr int
    EXEC @hr = sp_OACreate 'Chilkat.JsonArray', @jarr OUT

    EXEC sp_OAMethod @jarr, 'Load', @success OUT, @responseBody
    EXEC sp_OASetProperty @jarr, 'EmitCompact', 0
    EXEC sp_OAMethod @jarr, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    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

    -- [
    --   {
    --     "name": "House Projects",
    --     "desc": "",
    --     "descData": null,
    --     "closed": false,
    --     "idOrganization": null,
    --     "limits": null,
    --     "pinned": null,
    --     "shortLink": "j1hkQKKS",
    --     "powerUps": [
    --     ],
    --     "dateLastActivity": null,
    --     "idTags": [
    --     ],
    --     "datePluginDisable": null,
    --     "creationMethod": null,
    --     "ixUpdate": null,
    --     "id": "5cc5fe862106bb8e05aa41e7",
    --     "starred": false,
    --     "url": "https://trello.com/b/j1hkQKKS/house-projects",
    --     "prefs": {
    --       "permissionLevel": "private",
    --       "voting": "disabled",
    --       "comments": "members",
    --       "invitations": "members",
    --       "selfJoin": false,
    --       "cardCovers": true,
    --       "cardAging": "regular",
    --       "calendarFeedEnabled": false,
    --       "background": "5cc344f6ba4cdc5f5cfc7d81",
    --       "backgroundImage": "https://trello-backgrounds.s3.amazonaws.com/SharedBackground/2560x1709/4418c78f2f66d26932fef88aead2aff5/photo-1555985202-12975b0235dc",
    --       "backgroundImageScaled": [
    --         {
    --           "width": 140,
    --           "height": 93,
    --           "url": "https://trello-backgrounds.s3.amazonaws.com/SharedBackground/140x93/0aebced0ac2d8c9c4b9231b1960d28c2/photo-1555985202-12975b0235dc.jpg"
    --         },
    --  ...
    --         {
    --           "width": 2560,
    --           "height": 1709,
    --           "url": "https://trello-backgrounds.s3.amazonaws.com/SharedBackground/2560x1709/4418c78f2f66d26932fef88aead2aff5/photo-1555985202-12975b0235dc"
    --         }
    --       ],
    --       "backgroundTile": false,
    --       "backgroundBrightness": "dark",
    --       "backgroundBottomColor": "#412f23",
    --       "backgroundTopColor": "#a99d97",
    --       "canBePublic": true,
    --       "canBeEnterprise": true,
    --       "canBeOrg": true,
    --       "canBePrivate": true,
    --       "canInvite": true
    --     },
    --     "subscribed": false,
    --     "labelNames": {
    --       "green": "",
    --       "yellow": "",
    --       "orange": "",
    --       "red": "",
    --       "purple": "",
    --       "blue": "",
    --       "sky": "",
    --       "lime": "",
    --       "pink": "",
    --       "black": ""
    --     },
    --     "dateLastView": "2019-04-28T19:28:18.159Z",
    --     "shortUrl": "https://trello.com/b/j1hkQKKS",
    --     "memberships": [
    --       {
    --         "id": "5cc5fe862106bb8e05aa41e8",
    --         "idMember": "5cc5c74067d5215921ca7677",
    --         "memberType": "admin",
    --         "unconfirmed": false,
    --         "deactivated": false
    --       }
    --     ]
    --   },
    --   {
    --     "name": "Vacation Planning",
    --     "desc": "",
    --     "descData": null,
    --     "closed": false,
    --     "idOrganization": null,
    --     "limits": null,
    --     "pinned": null,
    --     "shortLink": "QqIHvQyz",
    --     "powerUps": [
    --     ],
    --     "dateLastActivity": "2019-04-28T15:32:20.134Z",
    --     "idTags": [
    --     ],
    --     "datePluginDisable": null,
    --     "creationMethod": "assisted",
    --     "ixUpdate": null,
    --     "id": "5cc5c783f5b10f8717a6b3d6",
    --     "starred": false,
    --     "url": "https://trello.com/b/QqIHvQyz/vacation-planning",
    --     "prefs": {
    --       "permissionLevel": "private",
    --       "voting": "disabled",
    --       "comments": "members",
    --       "invitations": "members",
    --       "selfJoin": true,
    --       "cardCovers": true,
    --       "cardAging": "regular",
    --       "calendarFeedEnabled": false,
    --       "background": "lime",
    --       "backgroundImage": null,
    --       "backgroundImageScaled": null,
    --       "backgroundTile": false,
    --       "backgroundBrightness": "dark",
    --       "backgroundColor": "#4BBF6B",
    --       "backgroundBottomColor": "#4BBF6B",
    --       "backgroundTopColor": "#4BBF6B",
    --       "canBePublic": true,
    --       "canBeEnterprise": true,
    --       "canBeOrg": true,
    --       "canBePrivate": true,
    --       "canInvite": true
    --     },
    --     "subscribed": false,
    --     "labelNames": {
    --       "green": "",
    --       "yellow": "",
    --       "orange": "",
    --       "red": "",
    --       "purple": "",
    --       "blue": "",
    --       "sky": "",
    --       "lime": "",
    --       "pink": "",
    --       "black": ""
    --     },
    --     "dateLastView": "2019-04-28T19:32:21.009Z",
    --     "shortUrl": "https://trello.com/b/QqIHvQyz",
    --     "memberships": [
    --       {
    --         "id": "5cc5c783f5b10f8717a6b3d7",
    --         "idMember": "5cc5c74067d5215921ca7677",
    --         "memberType": "admin",
    --         "unconfirmed": false,
    --         "deactivated": false
    --       }
    --     ]
    --   }
    -- ]

    DECLARE @i int

    DECLARE @count_i int

    DECLARE @json int

    DECLARE @name nvarchar(4000)

    DECLARE @desc nvarchar(4000)

    DECLARE @descData nvarchar(4000)

    DECLARE @closed int

    DECLARE @idOrganization nvarchar(4000)

    DECLARE @limits nvarchar(4000)

    DECLARE @pinned nvarchar(4000)

    DECLARE @shortLink nvarchar(4000)

    DECLARE @dateLastActivity nvarchar(4000)

    DECLARE @datePluginDisable nvarchar(4000)

    DECLARE @creationMethod nvarchar(4000)

    DECLARE @ixUpdate nvarchar(4000)

    DECLARE @id nvarchar(4000)

    DECLARE @starred int

    DECLARE @url nvarchar(4000)

    DECLARE @prefsPermissionLevel nvarchar(4000)

    DECLARE @prefsVoting nvarchar(4000)

    DECLARE @prefsComments nvarchar(4000)

    DECLARE @prefsInvitations nvarchar(4000)

    DECLARE @prefsSelfJoin int

    DECLARE @prefsCardCovers int

    DECLARE @prefsCardAging nvarchar(4000)

    DECLARE @prefsCalendarFeedEnabled int

    DECLARE @prefsBackground nvarchar(4000)

    DECLARE @prefsBackgroundImage nvarchar(4000)

    DECLARE @prefsBackgroundTile int

    DECLARE @prefsBackgroundBrightness nvarchar(4000)

    DECLARE @prefsBackgroundBottomColor nvarchar(4000)

    DECLARE @prefsBackgroundTopColor nvarchar(4000)

    DECLARE @prefsCanBePublic int

    DECLARE @prefsCanBeEnterprise int

    DECLARE @prefsCanBeOrg int

    DECLARE @prefsCanBePrivate int

    DECLARE @prefsCanInvite int

    DECLARE @subscribed int

    DECLARE @labelNamesGreen nvarchar(4000)

    DECLARE @labelNamesYellow nvarchar(4000)

    DECLARE @labelNamesOrange nvarchar(4000)

    DECLARE @labelNamesRed nvarchar(4000)

    DECLARE @labelNamesPurple nvarchar(4000)

    DECLARE @labelNamesBlue nvarchar(4000)

    DECLARE @labelNamesSky nvarchar(4000)

    DECLARE @labelNamesLime nvarchar(4000)

    DECLARE @labelNamesPink nvarchar(4000)

    DECLARE @labelNamesBlack nvarchar(4000)

    DECLARE @dateLastView nvarchar(4000)

    DECLARE @shortUrl nvarchar(4000)

    DECLARE @prefsBackgroundImageScaled nvarchar(4000)

    DECLARE @prefsBackgroundColor nvarchar(4000)

    DECLARE @j int

    DECLARE @count_j int

    DECLARE @width int

    DECLARE @height int

    DECLARE @idMember nvarchar(4000)

    DECLARE @memberType nvarchar(4000)

    DECLARE @unconfirmed int

    DECLARE @deactivated int

    SELECT @i = 0
    EXEC sp_OAGetProperty @jarr, 'Size', @count_i OUT
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OAMethod @jarr, 'ObjectAt', @json OUT, @i
        EXEC sp_OAMethod @json, 'StringOf', @name OUT, 'name'
        EXEC sp_OAMethod @json, 'StringOf', @desc OUT, 'desc'
        EXEC sp_OAMethod @json, 'StringOf', @descData OUT, 'descData'
        EXEC sp_OAMethod @json, 'BoolOf', @closed OUT, 'closed'
        EXEC sp_OAMethod @json, 'StringOf', @idOrganization OUT, 'idOrganization'
        EXEC sp_OAMethod @json, 'StringOf', @limits OUT, 'limits'
        EXEC sp_OAMethod @json, 'StringOf', @pinned OUT, 'pinned'
        EXEC sp_OAMethod @json, 'StringOf', @shortLink OUT, 'shortLink'
        EXEC sp_OAMethod @json, 'StringOf', @dateLastActivity OUT, 'dateLastActivity'
        EXEC sp_OAMethod @json, 'StringOf', @datePluginDisable OUT, 'datePluginDisable'
        EXEC sp_OAMethod @json, 'StringOf', @creationMethod OUT, 'creationMethod'
        EXEC sp_OAMethod @json, 'StringOf', @ixUpdate OUT, 'ixUpdate'
        EXEC sp_OAMethod @json, 'StringOf', @id OUT, 'id'
        EXEC sp_OAMethod @json, 'BoolOf', @starred OUT, 'starred'
        EXEC sp_OAMethod @json, 'StringOf', @url OUT, 'url'
        EXEC sp_OAMethod @json, 'StringOf', @prefsPermissionLevel OUT, 'prefs.permissionLevel'
        EXEC sp_OAMethod @json, 'StringOf', @prefsVoting OUT, 'prefs.voting'
        EXEC sp_OAMethod @json, 'StringOf', @prefsComments OUT, 'prefs.comments'
        EXEC sp_OAMethod @json, 'StringOf', @prefsInvitations OUT, 'prefs.invitations'
        EXEC sp_OAMethod @json, 'BoolOf', @prefsSelfJoin OUT, 'prefs.selfJoin'
        EXEC sp_OAMethod @json, 'BoolOf', @prefsCardCovers OUT, 'prefs.cardCovers'
        EXEC sp_OAMethod @json, 'StringOf', @prefsCardAging OUT, 'prefs.cardAging'
        EXEC sp_OAMethod @json, 'BoolOf', @prefsCalendarFeedEnabled OUT, 'prefs.calendarFeedEnabled'
        EXEC sp_OAMethod @json, 'StringOf', @prefsBackground OUT, 'prefs.background'
        EXEC sp_OAMethod @json, 'StringOf', @prefsBackgroundImage OUT, 'prefs.backgroundImage'
        EXEC sp_OAMethod @json, 'BoolOf', @prefsBackgroundTile OUT, 'prefs.backgroundTile'
        EXEC sp_OAMethod @json, 'StringOf', @prefsBackgroundBrightness OUT, 'prefs.backgroundBrightness'
        EXEC sp_OAMethod @json, 'StringOf', @prefsBackgroundBottomColor OUT, 'prefs.backgroundBottomColor'
        EXEC sp_OAMethod @json, 'StringOf', @prefsBackgroundTopColor OUT, 'prefs.backgroundTopColor'
        EXEC sp_OAMethod @json, 'BoolOf', @prefsCanBePublic OUT, 'prefs.canBePublic'
        EXEC sp_OAMethod @json, 'BoolOf', @prefsCanBeEnterprise OUT, 'prefs.canBeEnterprise'
        EXEC sp_OAMethod @json, 'BoolOf', @prefsCanBeOrg OUT, 'prefs.canBeOrg'
        EXEC sp_OAMethod @json, 'BoolOf', @prefsCanBePrivate OUT, 'prefs.canBePrivate'
        EXEC sp_OAMethod @json, 'BoolOf', @prefsCanInvite OUT, 'prefs.canInvite'
        EXEC sp_OAMethod @json, 'BoolOf', @subscribed OUT, 'subscribed'
        EXEC sp_OAMethod @json, 'StringOf', @labelNamesGreen OUT, 'labelNames.green'
        EXEC sp_OAMethod @json, 'StringOf', @labelNamesYellow OUT, 'labelNames.yellow'
        EXEC sp_OAMethod @json, 'StringOf', @labelNamesOrange OUT, 'labelNames.orange'
        EXEC sp_OAMethod @json, 'StringOf', @labelNamesRed OUT, 'labelNames.red'
        EXEC sp_OAMethod @json, 'StringOf', @labelNamesPurple OUT, 'labelNames.purple'
        EXEC sp_OAMethod @json, 'StringOf', @labelNamesBlue OUT, 'labelNames.blue'
        EXEC sp_OAMethod @json, 'StringOf', @labelNamesSky OUT, 'labelNames.sky'
        EXEC sp_OAMethod @json, 'StringOf', @labelNamesLime OUT, 'labelNames.lime'
        EXEC sp_OAMethod @json, 'StringOf', @labelNamesPink OUT, 'labelNames.pink'
        EXEC sp_OAMethod @json, 'StringOf', @labelNamesBlack OUT, 'labelNames.black'
        EXEC sp_OAMethod @json, 'StringOf', @dateLastView OUT, 'dateLastView'
        EXEC sp_OAMethod @json, 'StringOf', @shortUrl OUT, 'shortUrl'
        EXEC sp_OAMethod @json, 'StringOf', @prefsBackgroundImageScaled OUT, 'prefs.backgroundImageScaled'
        EXEC sp_OAMethod @json, 'StringOf', @prefsBackgroundColor OUT, 'prefs.backgroundColor'
        SELECT @j = 0
        EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'powerUps'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @json, 'J', @j
            -- ...
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'idTags'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @json, 'J', @j
            -- ...
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'prefs.backgroundImageScaled'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @json, 'J', @j
            EXEC sp_OAMethod @json, 'IntOf', @width OUT, 'prefs.backgroundImageScaled[j].width'
            EXEC sp_OAMethod @json, 'IntOf', @height OUT, 'prefs.backgroundImageScaled[j].height'
            EXEC sp_OAMethod @json, 'StringOf', @url OUT, 'prefs.backgroundImageScaled[j].url'
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'memberships'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @json, 'J', @j
            EXEC sp_OAMethod @json, 'StringOf', @id OUT, 'memberships[j].id'
            EXEC sp_OAMethod @json, 'StringOf', @idMember OUT, 'memberships[j].idMember'
            EXEC sp_OAMethod @json, 'StringOf', @memberType OUT, 'memberships[j].memberType'
            EXEC sp_OAMethod @json, 'BoolOf', @unconfirmed OUT, 'memberships[j].unconfirmed'
            EXEC sp_OAMethod @json, 'BoolOf', @deactivated OUT, 'memberships[j].deactivated'
            SELECT @j = @j + 1
          END
        EXEC @hr = sp_OADestroy @json

        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @jsonToken
    EXEC @hr = sp_OADestroy @oauth1
    EXEC @hr = sp_OADestroy @rest
    EXEC @hr = sp_OADestroy @jarr


END
GO