Chilkat Online Tools

SQL Server / Atlassian Confluence Cloud / Get spaces

Back to Collection Items

-- 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)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    DECLARE @queryParams int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'spaceKey', '<string>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'spaceKey', '<string>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'spaceId', '<long>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'spaceId', '<long>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'type', '<string>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'status', '<string>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'label', '<string>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'label', '<string>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'favourite', '<boolean>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'favouriteUserKey', '<string>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'expand', '<string>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'expand', '<string>'
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'start', 0
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'limit', 25

    -- Adds the "Authorization: Bearer <access_token>" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://your-domain.atlassian.net/wiki/rest/api/space', @queryParams
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        RETURN
      END

    DECLARE @sbResponseBody int
    -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody

    DECLARE @jResp int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @resp

        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END
    EXEC @hr = sp_OADestroy @resp

    -- Sample JSON response:
    -- (Sample code for parsing the JSON response is shown below)

    -- {
    --   "results": [
    --     {
    --       "id": 26764331,
    --       "key": "laborum",
    --       "name": "in adipisicing nisi",
    --       "type": "sunt",
    --       "status": "laborum voluptate",
    --       "_expandable": {
    --         "settings": "sit occaecat",
    --         "metadata": "",
    --         "operations": "sunt do culpa ullamco",
    --         "lookAndFeel": "Lorem occaecat",
    --         "permissions": "cupidatat dolore elit et",
    --         "icon": "occaecat Excepteur",
    --         "description": "consectetur id Excepteur mollit",
    --         "theme": "volupt",
    --         "history": "est laboris adipisicing occaecat non",
    --         "homepage": "in laboris"
    --       },
    --       "_links": {},
    --       "icon": {
    --         "path": "irure ut",
    --         "width": 74794118,
    --         "height": 55813977,
    --         "isDefault": false
    --       },
    --       "description": {
    --         "plain": {
    --           "value": "Lorem",
    --           "representation": "plain",
    --           "embeddedContent": [
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             }
    --           ]
    --         },
    --         "view": {
    --           "value": "officia sunt velit",
    --           "representation": "plain",
    --           "embeddedContent": [
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             }
    --           ]
    --         }
    --       },
    --       "homepage": {
    --         "value": "<Circular reference to #/components/schemas/Content detected>"
    --       },
    --       "metadata": {
    --         "labels": {
    --           "results": [
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             }
    --           ],
    --           "start": -83054779,
    --           "limit": 97968975,
    --           "size": -70611604,
    --           "_links": {}
    --         }
    --       },
    --       "operations": [
    --         {
    --           "operation": "copy",
    --           "targetType": "blogpost"
    --         },
    --         {
    --           "operation": "update",
    --           "targetType": "blogpost"
    --         }
    --       ],
    --       "permissions": [
    --         {
    --           "subjects": {
    --             "_expandable": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             "user": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             "group": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             }
    --           },
    --           "operation": {
    --             "operation": "administer",
    --             "targetType": "application"
    --           },
    --           "anonymousAccess": false,
    --           "unlicensedAccess": false
    --         },
    --         {
    --           "subjects": {
    --             "_expandable": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             "user": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             "group": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             }
    --           },
    --           "operation": {
    --             "operation": "move",
    --             "targetType": "comment"
    --           },
    --           "anonymousAccess": false,
    --           "unlicensedAccess": false
    --         }
    --       ],
    --       "settings": {
    --         "routeOverrideEnabled": false,
    --         "_links": {}
    --       },
    --       "theme": {},
    --       "lookAndFeel": {
    --         "headings": {
    --           "color": "<string>"
    --         },
    --         "links": {
    --           "color": "<string>"
    --         },
    --         "menus": {
    --           "hoverOrFocus": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "color": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           }
    --         },
    --         "header": {
    --           "backgroundColor": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "button": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "primaryNavigation": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "secondaryNavigation": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "search": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           }
    --         },
    --         "content": {
    --           "screen": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "container": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "header": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "body": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           }
    --         },
    --         "bordersAndDividers": {
    --           "color": "<string>"
    --         }
    --       },
    --       "history": {
    --         "createdDate": "1999-07-22T04:19:16.365Z"
    --       }
    --     },
    --     {
    --       "id": -19509015,
    --       "key": "tempor veniam commodo aute pariatur",
    --       "name": "id velit ex sit",
    --       "type": "quis officia cillum",
    --       "status": "officia ipsum proident irure culpa",
    --       "_expandable": {
    --         "settings": "aute non",
    --         "metadata": "laborum do deserunt",
    --         "operations": "Duis occaecat Excepteur",
    --         "lookAndFeel": "esse",
    --         "permissions": "mollit id in Excepteur",
    --         "icon": "elit velit m",
    --         "description": "magna ipsum dolor nisi",
    --         "theme": "cupidatat ex ",
    --         "history": "ipsum esse",
    --         "homepage": "ipsum commodo officia"
    --       },
    --       "_links": {},
    --       "icon": {
    --         "path": "occaecat enim mollit",
    --         "width": 28738893,
    --         "height": 88604543,
    --         "isDefault": true
    --       },
    --       "description": {
    --         "plain": {
    --           "value": "amet Excepteur aliquip qui",
    --           "representation": "plain",
    --           "embeddedContent": [
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             }
    --           ]
    --         },
    --         "view": {
    --           "value": "in tempor",
    --           "representation": "plain",
    --           "embeddedContent": [
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             }
    --           ]
    --         }
    --       },
    --       "homepage": {
    --         "value": "<Circular reference to #/components/schemas/Content detected>"
    --       },
    --       "metadata": {
    --         "labels": {
    --           "results": [
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             }
    --           ],
    --           "start": 33084561,
    --           "limit": -91985267,
    --           "size": -56212284,
    --           "_links": {}
    --         }
    --       },
    --       "operations": [
    --         {
    --           "operation": "move",
    --           "targetType": "space"
    --         },
    --         {
    --           "operation": "administer",
    --           "targetType": "space"
    --         }
    --       ],
    --       "permissions": [
    --         {
    --           "subjects": {
    --             "_expandable": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             "user": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             "group": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             }
    --           },
    --           "operation": {
    --             "operation": "restore",
    --             "targetType": "attachment"
    --           },
    --           "anonymousAccess": false,
    --           "unlicensedAccess": false
    --         },
    --         {
    --           "subjects": {
    --             "_expandable": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             "user": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             },
    --             "group": {
    --               "value": "<Error: Too many levels of nesting to fake this schema>"
    --             }
    --           },
    --           "operation": {
    --             "operation": "purge",
    --             "targetType": "blogpost"
    --           },
    --           "anonymousAccess": false,
    --           "unlicensedAccess": false
    --         }
    --       ],
    --       "settings": {
    --         "routeOverrideEnabled": false,
    --         "_links": {}
    --       },
    --       "theme": {},
    --       "lookAndFeel": {
    --         "headings": {
    --           "color": "<string>"
    --         },
    --         "links": {
    --           "color": "<string>"
    --         },
    --         "menus": {
    --           "hoverOrFocus": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "color": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           }
    --         },
    --         "header": {
    --           "backgroundColor": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "button": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "primaryNavigation": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "secondaryNavigation": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "search": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           }
    --         },
    --         "content": {
    --           "screen": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "container": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "header": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           },
    --           "body": {
    --             "value": "<Error: Too many levels of nesting to fake this schema>"
    --           }
    --         },
    --         "bordersAndDividers": {
    --           "color": "<string>"
    --         }
    --       },
    --       "history": {
    --         "createdDate": "1988-11-10T03:26:30.943Z"
    --       }
    --     }
    --   ],
    --   "start": -704604,
    --   "limit": 17139756,
    --   "size": 86679250,
    --   "_links": {}
    -- }

    -- Sample code for parsing the JSON response...
    -- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    DECLARE @id int

    DECLARE @key nvarchar(4000)

    DECLARE @name nvarchar(4000)

    DECLARE @v_type nvarchar(4000)

    DECLARE @status nvarchar(4000)

    DECLARE @Settings nvarchar(4000)

    DECLARE @Metadata nvarchar(4000)

    DECLARE @Operations nvarchar(4000)

    DECLARE @LookAndFeel nvarchar(4000)

    DECLARE @Permissions nvarchar(4000)

    DECLARE @Icon nvarchar(4000)

    DECLARE @Description nvarchar(4000)

    DECLARE @Theme nvarchar(4000)

    DECLARE @History nvarchar(4000)

    DECLARE @Homepage nvarchar(4000)

    DECLARE @Path nvarchar(4000)

    DECLARE @Width int

    DECLARE @Height int

    DECLARE @IsDefault int

    DECLARE @Value nvarchar(4000)

    DECLARE @Representation nvarchar(4000)

    DECLARE @ViewValue nvarchar(4000)

    DECLARE @ViewRepresentation nvarchar(4000)

    DECLARE @homepageValue nvarchar(4000)

    DECLARE @Start int

    DECLARE @Limit int

    DECLARE @Size int

    DECLARE @RouteOverrideEnabled int

    DECLARE @Color nvarchar(4000)

    DECLARE @LinksColor nvarchar(4000)

    DECLARE @HoverOrFocusValue nvarchar(4000)

    DECLARE @ColorValue nvarchar(4000)

    DECLARE @BackgroundColorValue nvarchar(4000)

    DECLARE @ButtonValue nvarchar(4000)

    DECLARE @PrimaryNavigationValue nvarchar(4000)

    DECLARE @SecondaryNavigationValue nvarchar(4000)

    DECLARE @SearchValue nvarchar(4000)

    DECLARE @ScreenValue nvarchar(4000)

    DECLARE @ContainerValue nvarchar(4000)

    DECLARE @HeaderValue nvarchar(4000)

    DECLARE @BodyValue nvarchar(4000)

    DECLARE @BordersAndDividersColor nvarchar(4000)

    DECLARE @CreatedDate nvarchar(4000)

    DECLARE @j int

    DECLARE @count_j int

    DECLARE @value nvarchar(4000)

    DECLARE @operation nvarchar(4000)

    DECLARE @targetType nvarchar(4000)

    DECLARE @v_expandableValue nvarchar(4000)

    DECLARE @UserValue nvarchar(4000)

    DECLARE @GroupValue nvarchar(4000)

    DECLARE @Operation nvarchar(4000)

    DECLARE @TargetType nvarchar(4000)

    DECLARE @anonymousAccess int

    DECLARE @unlicensedAccess int

    DECLARE @start int
    EXEC sp_OAMethod @jResp, 'IntOf', @start OUT, 'start'
    DECLARE @limit int
    EXEC sp_OAMethod @jResp, 'IntOf', @limit OUT, 'limit'
    DECLARE @size int
    EXEC sp_OAMethod @jResp, 'IntOf', @size OUT, 'size'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'results'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'IntOf', @id OUT, 'results[i].id'
        EXEC sp_OAMethod @jResp, 'StringOf', @key OUT, 'results[i].key'
        EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'results[i].name'
        EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'results[i].type'
        EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'results[i].status'
        EXEC sp_OAMethod @jResp, 'StringOf', @Settings OUT, 'results[i]._expandable.settings'
        EXEC sp_OAMethod @jResp, 'StringOf', @Metadata OUT, 'results[i]._expandable.metadata'
        EXEC sp_OAMethod @jResp, 'StringOf', @Operations OUT, 'results[i]._expandable.operations'
        EXEC sp_OAMethod @jResp, 'StringOf', @LookAndFeel OUT, 'results[i]._expandable.lookAndFeel'
        EXEC sp_OAMethod @jResp, 'StringOf', @Permissions OUT, 'results[i]._expandable.permissions'
        EXEC sp_OAMethod @jResp, 'StringOf', @Icon OUT, 'results[i]._expandable.icon'
        EXEC sp_OAMethod @jResp, 'StringOf', @Description OUT, 'results[i]._expandable.description'
        EXEC sp_OAMethod @jResp, 'StringOf', @Theme OUT, 'results[i]._expandable.theme'
        EXEC sp_OAMethod @jResp, 'StringOf', @History OUT, 'results[i]._expandable.history'
        EXEC sp_OAMethod @jResp, 'StringOf', @Homepage OUT, 'results[i]._expandable.homepage'
        EXEC sp_OAMethod @jResp, 'StringOf', @Path OUT, 'results[i].icon.path'
        EXEC sp_OAMethod @jResp, 'IntOf', @Width OUT, 'results[i].icon.width'
        EXEC sp_OAMethod @jResp, 'IntOf', @Height OUT, 'results[i].icon.height'
        EXEC sp_OAMethod @jResp, 'BoolOf', @IsDefault OUT, 'results[i].icon.isDefault'
        EXEC sp_OAMethod @jResp, 'StringOf', @Value OUT, 'results[i].description.plain.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @Representation OUT, 'results[i].description.plain.representation'
        EXEC sp_OAMethod @jResp, 'StringOf', @ViewValue OUT, 'results[i].description.view.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @ViewRepresentation OUT, 'results[i].description.view.representation'
        EXEC sp_OAMethod @jResp, 'StringOf', @homepageValue OUT, 'results[i].homepage.value'
        EXEC sp_OAMethod @jResp, 'IntOf', @Start OUT, 'results[i].metadata.labels.start'
        EXEC sp_OAMethod @jResp, 'IntOf', @Limit OUT, 'results[i].metadata.labels.limit'
        EXEC sp_OAMethod @jResp, 'IntOf', @Size OUT, 'results[i].metadata.labels.size'
        EXEC sp_OAMethod @jResp, 'BoolOf', @RouteOverrideEnabled OUT, 'results[i].settings.routeOverrideEnabled'
        EXEC sp_OAMethod @jResp, 'StringOf', @Color OUT, 'results[i].lookAndFeel.headings.color'
        EXEC sp_OAMethod @jResp, 'StringOf', @LinksColor OUT, 'results[i].lookAndFeel.links.color'
        EXEC sp_OAMethod @jResp, 'StringOf', @HoverOrFocusValue OUT, 'results[i].lookAndFeel.menus.hoverOrFocus.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @ColorValue OUT, 'results[i].lookAndFeel.menus.color.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @BackgroundColorValue OUT, 'results[i].lookAndFeel.header.backgroundColor.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @ButtonValue OUT, 'results[i].lookAndFeel.header.button.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @PrimaryNavigationValue OUT, 'results[i].lookAndFeel.header.primaryNavigation.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @SecondaryNavigationValue OUT, 'results[i].lookAndFeel.header.secondaryNavigation.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @SearchValue OUT, 'results[i].lookAndFeel.header.search.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @ScreenValue OUT, 'results[i].lookAndFeel.content.screen.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @ContainerValue OUT, 'results[i].lookAndFeel.content.container.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @HeaderValue OUT, 'results[i].lookAndFeel.content.header.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @BodyValue OUT, 'results[i].lookAndFeel.content.body.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @BordersAndDividersColor OUT, 'results[i].lookAndFeel.bordersAndDividers.color'
        EXEC sp_OAMethod @jResp, 'StringOf', @CreatedDate OUT, 'results[i].history.createdDate'
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'results[i].description.plain.embeddedContent'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'results[i].description.plain.embeddedContent[j].value'
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'results[i].description.view.embeddedContent'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'results[i].description.view.embeddedContent[j].value'
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'results[i].metadata.labels.results'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'results[i].metadata.labels.results[j].value'
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'results[i].operations'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @operation OUT, 'results[i].operations[j].operation'
            EXEC sp_OAMethod @jResp, 'StringOf', @targetType OUT, 'results[i].operations[j].targetType'
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'results[i].permissions'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @v_expandableValue OUT, 'results[i].permissions[j].subjects._expandable.value'
            EXEC sp_OAMethod @jResp, 'StringOf', @UserValue OUT, 'results[i].permissions[j].subjects.user.value'
            EXEC sp_OAMethod @jResp, 'StringOf', @GroupValue OUT, 'results[i].permissions[j].subjects.group.value'
            EXEC sp_OAMethod @jResp, 'StringOf', @Operation OUT, 'results[i].permissions[j].operation.operation'
            EXEC sp_OAMethod @jResp, 'StringOf', @TargetType OUT, 'results[i].permissions[j].operation.targetType'
            EXEC sp_OAMethod @jResp, 'BoolOf', @anonymousAccess OUT, 'results[i].permissions[j].anonymousAccess'
            EXEC sp_OAMethod @jResp, 'BoolOf', @unlicensedAccess OUT, 'results[i].permissions[j].unlicensedAccess'
            SELECT @j = @j + 1
          END
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @queryParams
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

Curl Command

curl -G -d "spaceKey=%3Cstring%3E"
	-d "spaceKey=%3Cstring%3E"
	-d "spaceId=%3Clong%3E"
	-d "spaceId=%3Clong%3E"
	-d "type=%3Cstring%3E"
	-d "status=%3Cstring%3E"
	-d "label=%3Cstring%3E"
	-d "label=%3Cstring%3E"
	-d "favourite=%3Cboolean%3E"
	-d "favouriteUserKey=%3Cstring%3E"
	-d "expand=%3Cstring%3E"
	-d "expand=%3Cstring%3E"
	-d "start=0"
	-d "limit=25"
	-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/space

Postman Collection Item JSON

{
  "name": "Get spaces",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/space?spaceKey=<string>&spaceKey=<string>&spaceId=<long>&spaceId=<long>&type=<string>&status=<string>&label=<string>&label=<string>&favourite=<boolean>&favouriteUserKey=<string>&expand=<string>&expand=<string>&start=0&limit=25",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "space"
      ],
      "query": [
        {
          "key": "spaceKey",
          "value": "<string>",
          "description": "The key of the space to be returned. To return multiple spaces,\nspecify this parameter multiple times with different values."
        },
        {
          "key": "spaceKey",
          "value": "<string>",
          "description": "The key of the space to be returned. To return multiple spaces,\nspecify this parameter multiple times with different values."
        },
        {
          "key": "spaceId",
          "value": "<long>",
          "description": "The id of the space to be returned. To return multiple spaces,\nspecify this parameter multiple times with different values."
        },
        {
          "key": "spaceId",
          "value": "<long>",
          "description": "The id of the space to be returned. To return multiple spaces,\nspecify this parameter multiple times with different values."
        },
        {
          "key": "type",
          "value": "<string>",
          "description": "Filter the results to spaces based on their type."
        },
        {
          "key": "status",
          "value": "<string>",
          "description": "Filter the results to spaces based on their status."
        },
        {
          "key": "label",
          "value": "<string>",
          "description": "Filter the results to spaces based on their label."
        },
        {
          "key": "label",
          "value": "<string>",
          "description": "Filter the results to spaces based on their label."
        },
        {
          "key": "favourite",
          "value": "<boolean>",
          "description": "Filter the results to the favourite spaces of the user specified by\n`favouriteUserKey`. Note, 'favourite' spaces are also\nknown as 'saved for later' spaces."
        },
        {
          "key": "favouriteUserKey",
          "value": "<string>",
          "description": "The userKey of the user, whose favourite spaces are used to filter\nthe results when using the `favourite` parameter.\n\nLeave blank for the current user. Use [Get user](#api-user-get) to\nget the userKey for a user."
        },
        {
          "key": "expand",
          "value": "<string>",
          "description": "A multi-value parameter indicating which properties of the spaces to\nexpand, where:\n\n  - `settings` returns the settings for the space, similar to [Get space settings](#api-space-spaceKey-settings-get).\n  - `metadata.labels` returns the space labels, which are used to categorize the space.\n  - `operations` returns the operations for a space, which are used when setting permissions.\n  - `lookAndFeel` returns information about the look and feel of the space, including the color scheme.\n  - `permissions` returns the permissions for the space. Note that this may return permissions for deleted groups,\n  because deleting a group doesn't remove associated space permissions.\n  - `icon` returns information about space icon.\n  - `description.plain` returns the description of the space.\n  - `description.view` returns the description of the space.\n  - `theme` returns information about the space theme.\n  - `homepage` returns information about the space homepage."
        },
        {
          "key": "expand",
          "value": "<string>",
          "description": "A multi-value parameter indicating which properties of the spaces to\nexpand, where:\n\n  - `settings` returns the settings for the space, similar to [Get space settings](#api-space-spaceKey-settings-get).\n  - `metadata.labels` returns the space labels, which are used to categorize the space.\n  - `operations` returns the operations for a space, which are used when setting permissions.\n  - `lookAndFeel` returns information about the look and feel of the space, including the color scheme.\n  - `permissions` returns the permissions for the space. Note that this may return permissions for deleted groups,\n  because deleting a group doesn't remove associated space permissions.\n  - `icon` returns information about space icon.\n  - `description.plain` returns the description of the space.\n  - `description.view` returns the description of the space.\n  - `theme` returns information about the space theme.\n  - `homepage` returns information about the space homepage."
        },
        {
          "key": "start",
          "value": "0",
          "description": "The starting index of the returned spaces."
        },
        {
          "key": "limit",
          "value": "25",
          "description": "The maximum number of spaces to return per page. Note, this may be\nrestricted by fixed system limits."
        }
      ]
    },
    "description": "Returns all spaces. The returned spaces are ordered alphabetically in\nascending order by space key.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\nPermission to access the Confluence site ('Can use' global permission).\nNote, the returned list will only contain spaces that the current user\nhas permission to view."
  },
  "response": [
    {
      "name": "Returned if the requested spaces are returned.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/space?spaceKey=<string>&spaceKey=<string>&spaceId=<long>&spaceId=<long>&type=<string>&status=<string>&label=<string>&label=<string>&favourite=<boolean>&favouriteUserKey=<string>&expand=<string>&expand=<string>&start=0&limit=25",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "space"
          ],
          "query": [
            {
              "key": "spaceKey",
              "value": "<string>"
            },
            {
              "key": "spaceKey",
              "value": "<string>"
            },
            {
              "key": "spaceId",
              "value": "<long>"
            },
            {
              "key": "spaceId",
              "value": "<long>"
            },
            {
              "key": "type",
              "value": "<string>"
            },
            {
              "key": "status",
              "value": "<string>"
            },
            {
              "key": "label",
              "value": "<string>"
            },
            {
              "key": "label",
              "value": "<string>"
            },
            {
              "key": "favourite",
              "value": "<boolean>"
            },
            {
              "key": "favouriteUserKey",
              "value": "<string>"
            },
            {
              "key": "expand",
              "value": "<string>"
            },
            {
              "key": "expand",
              "value": "<string>"
            },
            {
              "key": "start",
              "value": "0"
            },
            {
              "key": "limit",
              "value": "25"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"results\": [\n  {\n   \"id\": 26764331,\n   \"key\": \"laborum\",\n   \"name\": \"in adipisicing nisi\",\n   \"type\": \"sunt\",\n   \"status\": \"laborum voluptate\",\n   \"_expandable\": {\n    \"settings\": \"sit occaecat\",\n    \"metadata\": \"\",\n    \"operations\": \"sunt do culpa ullamco\",\n    \"lookAndFeel\": \"Lorem occaecat\",\n    \"permissions\": \"cupidatat dolore elit et\",\n    \"icon\": \"occaecat Excepteur\",\n    \"description\": \"consectetur id Excepteur mollit\",\n    \"theme\": \"volupt\",\n    \"history\": \"est laboris adipisicing occaecat non\",\n    \"homepage\": \"in laboris\"\n   },\n   \"_links\": {},\n   \"icon\": {\n    \"path\": \"irure ut\",\n    \"width\": 74794118,\n    \"height\": 55813977,\n    \"isDefault\": false\n   },\n   \"description\": {\n    \"plain\": {\n     \"value\": \"Lorem\",\n     \"representation\": \"plain\",\n     \"embeddedContent\": [\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      }\n     ]\n    },\n    \"view\": {\n     \"value\": \"officia sunt velit\",\n     \"representation\": \"plain\",\n     \"embeddedContent\": [\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      }\n     ]\n    }\n   },\n   \"homepage\": {\n    \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n   },\n   \"metadata\": {\n    \"labels\": {\n     \"results\": [\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      }\n     ],\n     \"start\": -83054779,\n     \"limit\": 97968975,\n     \"size\": -70611604,\n     \"_links\": {}\n    }\n   },\n   \"operations\": [\n    {\n     \"operation\": \"copy\",\n     \"targetType\": \"blogpost\"\n    },\n    {\n     \"operation\": \"update\",\n     \"targetType\": \"blogpost\"\n    }\n   ],\n   \"permissions\": [\n    {\n     \"subjects\": {\n      \"_expandable\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      \"user\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      \"group\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      }\n     },\n     \"operation\": {\n      \"operation\": \"administer\",\n      \"targetType\": \"application\"\n     },\n     \"anonymousAccess\": false,\n     \"unlicensedAccess\": false\n    },\n    {\n     \"subjects\": {\n      \"_expandable\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      \"user\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      \"group\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      }\n     },\n     \"operation\": {\n      \"operation\": \"move\",\n      \"targetType\": \"comment\"\n     },\n     \"anonymousAccess\": false,\n     \"unlicensedAccess\": false\n    }\n   ],\n   \"settings\": {\n    \"routeOverrideEnabled\": false,\n    \"_links\": {}\n   },\n   \"theme\": {},\n   \"lookAndFeel\": {\n    \"headings\": {\n     \"color\": \"<string>\"\n    },\n    \"links\": {\n     \"color\": \"<string>\"\n    },\n    \"menus\": {\n     \"hoverOrFocus\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"color\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     }\n    },\n    \"header\": {\n     \"backgroundColor\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"button\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"primaryNavigation\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"secondaryNavigation\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"search\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     }\n    },\n    \"content\": {\n     \"screen\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"container\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"header\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"body\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     }\n    },\n    \"bordersAndDividers\": {\n     \"color\": \"<string>\"\n    }\n   },\n   \"history\": {\n    \"createdDate\": \"1999-07-22T04:19:16.365Z\"\n   }\n  },\n  {\n   \"id\": -19509015,\n   \"key\": \"tempor veniam commodo aute pariatur\",\n   \"name\": \"id velit ex sit\",\n   \"type\": \"quis officia cillum\",\n   \"status\": \"officia ipsum proident irure culpa\",\n   \"_expandable\": {\n    \"settings\": \"aute non\",\n    \"metadata\": \"laborum do deserunt\",\n    \"operations\": \"Duis occaecat Excepteur\",\n    \"lookAndFeel\": \"esse\",\n    \"permissions\": \"mollit id in Excepteur\",\n    \"icon\": \"elit velit m\",\n    \"description\": \"magna ipsum dolor nisi\",\n    \"theme\": \"cupidatat ex \",\n    \"history\": \"ipsum esse\",\n    \"homepage\": \"ipsum commodo officia\"\n   },\n   \"_links\": {},\n   \"icon\": {\n    \"path\": \"occaecat enim mollit\",\n    \"width\": 28738893,\n    \"height\": 88604543,\n    \"isDefault\": true\n   },\n   \"description\": {\n    \"plain\": {\n     \"value\": \"amet Excepteur aliquip qui\",\n     \"representation\": \"plain\",\n     \"embeddedContent\": [\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      }\n     ]\n    },\n    \"view\": {\n     \"value\": \"in tempor\",\n     \"representation\": \"plain\",\n     \"embeddedContent\": [\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      }\n     ]\n    }\n   },\n   \"homepage\": {\n    \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n   },\n   \"metadata\": {\n    \"labels\": {\n     \"results\": [\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      }\n     ],\n     \"start\": 33084561,\n     \"limit\": -91985267,\n     \"size\": -56212284,\n     \"_links\": {}\n    }\n   },\n   \"operations\": [\n    {\n     \"operation\": \"move\",\n     \"targetType\": \"space\"\n    },\n    {\n     \"operation\": \"administer\",\n     \"targetType\": \"space\"\n    }\n   ],\n   \"permissions\": [\n    {\n     \"subjects\": {\n      \"_expandable\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      \"user\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      \"group\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      }\n     },\n     \"operation\": {\n      \"operation\": \"restore\",\n      \"targetType\": \"attachment\"\n     },\n     \"anonymousAccess\": false,\n     \"unlicensedAccess\": false\n    },\n    {\n     \"subjects\": {\n      \"_expandable\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      \"user\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      },\n      \"group\": {\n       \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n      }\n     },\n     \"operation\": {\n      \"operation\": \"purge\",\n      \"targetType\": \"blogpost\"\n     },\n     \"anonymousAccess\": false,\n     \"unlicensedAccess\": false\n    }\n   ],\n   \"settings\": {\n    \"routeOverrideEnabled\": false,\n    \"_links\": {}\n   },\n   \"theme\": {},\n   \"lookAndFeel\": {\n    \"headings\": {\n     \"color\": \"<string>\"\n    },\n    \"links\": {\n     \"color\": \"<string>\"\n    },\n    \"menus\": {\n     \"hoverOrFocus\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"color\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     }\n    },\n    \"header\": {\n     \"backgroundColor\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"button\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"primaryNavigation\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"secondaryNavigation\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"search\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     }\n    },\n    \"content\": {\n     \"screen\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"container\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"header\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"body\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     }\n    },\n    \"bordersAndDividers\": {\n     \"color\": \"<string>\"\n    }\n   },\n   \"history\": {\n    \"createdDate\": \"1988-11-10T03:26:30.943Z\"\n   }\n  }\n ],\n \"start\": -704604,\n \"limit\": 17139756,\n \"size\": 86679250,\n \"_links\": {}\n}"
    },
    {
      "name": "Returned if the authentication credentials are incorrect or missing\nfrom the request.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/space?spaceKey=<string>&spaceKey=<string>&spaceId=<long>&spaceId=<long>&type=<string>&status=<string>&label=<string>&label=<string>&favourite=<boolean>&favouriteUserKey=<string>&expand=<string>&expand=<string>&start=0&limit=25",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "space"
          ],
          "query": [
            {
              "key": "spaceKey",
              "value": "<string>"
            },
            {
              "key": "spaceKey",
              "value": "<string>"
            },
            {
              "key": "spaceId",
              "value": "<long>"
            },
            {
              "key": "spaceId",
              "value": "<long>"
            },
            {
              "key": "type",
              "value": "<string>"
            },
            {
              "key": "status",
              "value": "<string>"
            },
            {
              "key": "label",
              "value": "<string>"
            },
            {
              "key": "label",
              "value": "<string>"
            },
            {
              "key": "favourite",
              "value": "<boolean>"
            },
            {
              "key": "favouriteUserKey",
              "value": "<string>"
            },
            {
              "key": "expand",
              "value": "<string>"
            },
            {
              "key": "expand",
              "value": "<string>"
            },
            {
              "key": "start",
              "value": "0"
            },
            {
              "key": "limit",
              "value": "25"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}