Chilkat Online Tools

SQL Server / Atlassian Confluence Cloud / Create relationship

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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

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

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequest', @resp OUT, 'PUT', 'https://your-domain.atlassian.net/wiki/rest/api/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>'
    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
        RETURN
      END

    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

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

    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.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 @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)

    -- {
    --   "name": "laborum amet",
    --   "_expandable": {
    --     "relationData": "minim do quis",
    --     "source": "quis velit dolore ut",
    --     "target": "sint fugiat id repreh"
    --   },
    --   "_links": {},
    --   "relationData": {
    --     "createdBy": {
    --       "type": "known",
    --       "accountId": "est veniam nisi",
    --       "accountType": "atlassian",
    --       "email": "fugiat tempor est",
    --       "publicName": "proident cillum adipisicing",
    --       "profilePicture": {
    --         "path": "incididunt dolore sit in eu",
    --         "width": 66665902,
    --         "height": 7198703,
    --         "isDefault": false
    --       },
    --       "displayName": "mollit ex pariatur dolor",
    --       "_expandable": {
    --         "operations": "adipisicing in",
    --         "details": "id minim sed",
    --         "personalSpace": "Ut"
    --       },
    --       "_links": {},
    --       "username": "proident ut incididunt consequat",
    --       "userKey": "ipsum consequat sed ullamco aliquip",
    --       "operations": [
    --         {
    --           "operation": "copy",
    --           "targetType": "space"
    --         },
    --         {
    --           "operation": "purge_version",
    --           "targetType": "space"
    --         }
    --       ],
    --       "details": {
    --         "business": {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         },
    --         "personal": {
    --           "value": "<Error: Too many levels of nesting to fake this schema>"
    --         }
    --       },
    --       "personalSpace": {
    --         "id": 32251017,
    --         "key": "Excepteur do",
    --         "name": "est velit non",
    --         "type": "deserunt occaecat",
    --         "status": "in commodo incididunt non",
    --         "_expandable": {
    --           "settings": "ut cillum quis in",
    --           "metadata": "dolore minim",
    --           "operations": "anim commodo amet",
    --           "lookAndFeel": "dolore Lorem",
    --           "permissions": "dolore anim",
    --           "icon": "deserunt ex occaecat amet",
    --           "description": "cillum nostrud sint",
    --           "theme": "dolor id",
    --           "history": "in fugiat eu esse",
    --           "homepage": "et"
    --         },
    --         "_links": {},
    --         "icon": {
    --           "path": "laboris eiusmod Excepteur eu",
    --           "width": -89581460,
    --           "height": -66835718,
    --           "isDefault": true
    --         },
    --         "description": {
    --           "plain": {
    --             "value": "ut eu reprehenderit",
    --             "representation": "view",
    --             "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": "reprehenderit",
    --             "representation": "view",
    --             "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": 83305188,
    --             "limit": 81363289,
    --             "size": -91970205,
    --             "_links": {}
    --           }
    --         },
    --         "operations": [
    --           {
    --             "operation": "purge",
    --             "targetType": "comment"
    --           },
    --           {
    --             "operation": "use",
    --             "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": "purge_version",
    --               "targetType": "page"
    --             },
    --             "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": "administer",
    --               "targetType": "blogpost"
    --             },
    --             "anonymousAccess": false,
    --             "unlicensedAccess": false
    --           }
    --         ],
    --         "settings": {
    --           "routeOverrideEnabled": true,
    --           "_links": {}
    --         },
    --         "theme": {},
    --         "lookAndFeel": {
    --           "headings": {
    --             "color": "fugiat irure nostrud"
    --           },
    --           "links": {
    --             "color": "ad velit"
    --           },
    --           "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": "do in laborum"
    --           }
    --         },
    --         "history": {
    --           "createdDate": "1968-05-01T03:07:38.118Z"
    --         }
    --       }
    --     },
    --     "createdDate": "1955-09-27T16:15:59.770Z",
    --     "friendlyCreatedDate": "reprehenderit quis"
    --   },
    --   "source": {},
    --   "target": {}
    -- }

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

    DECLARE @operation nvarchar(4000)

    DECLARE @targetType nvarchar(4000)

    DECLARE @value 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 @name nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'name'
    DECLARE @RelationData nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @RelationData OUT, '_expandable.relationData'
    DECLARE @Source nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Source OUT, '_expandable.source'
    DECLARE @Target nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Target OUT, '_expandable.target'
    DECLARE @v_Type nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'relationData.createdBy.type'
    DECLARE @AccountId nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @AccountId OUT, 'relationData.createdBy.accountId'
    DECLARE @AccountType nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @AccountType OUT, 'relationData.createdBy.accountType'
    DECLARE @v_Email nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_Email OUT, 'relationData.createdBy.email'
    DECLARE @PublicName nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @PublicName OUT, 'relationData.createdBy.publicName'
    DECLARE @Path nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Path OUT, 'relationData.createdBy.profilePicture.path'
    DECLARE @Width int
    EXEC sp_OAMethod @jResp, 'IntOf', @Width OUT, 'relationData.createdBy.profilePicture.width'
    DECLARE @Height int
    EXEC sp_OAMethod @jResp, 'IntOf', @Height OUT, 'relationData.createdBy.profilePicture.height'
    DECLARE @IsDefault int
    EXEC sp_OAMethod @jResp, 'BoolOf', @IsDefault OUT, 'relationData.createdBy.profilePicture.isDefault'
    DECLARE @DisplayName nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @DisplayName OUT, 'relationData.createdBy.displayName'
    DECLARE @Operations nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Operations OUT, 'relationData.createdBy._expandable.operations'
    DECLARE @Details nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Details OUT, 'relationData.createdBy._expandable.details'
    DECLARE @PersonalSpace nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @PersonalSpace OUT, 'relationData.createdBy._expandable.personalSpace'
    DECLARE @Username nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Username OUT, 'relationData.createdBy.username'
    DECLARE @UserKey nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @UserKey OUT, 'relationData.createdBy.userKey'
    DECLARE @Value nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Value OUT, 'relationData.createdBy.details.business.value'
    DECLARE @PersonalValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @PersonalValue OUT, 'relationData.createdBy.details.personal.value'
    DECLARE @Id int
    EXEC sp_OAMethod @jResp, 'IntOf', @Id OUT, 'relationData.createdBy.personalSpace.id'
    DECLARE @Key nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Key OUT, 'relationData.createdBy.personalSpace.key'
    DECLARE @Name nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'relationData.createdBy.personalSpace.name'
    DECLARE @PersonalSpaceType nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @PersonalSpaceType OUT, 'relationData.createdBy.personalSpace.type'
    DECLARE @Status nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Status OUT, 'relationData.createdBy.personalSpace.status'
    DECLARE @Settings nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Settings OUT, 'relationData.createdBy.personalSpace._expandable.settings'
    DECLARE @Metadata nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Metadata OUT, 'relationData.createdBy.personalSpace._expandable.metadata'
    DECLARE @v_expandableOperations nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_expandableOperations OUT, 'relationData.createdBy.personalSpace._expandable.operations'
    DECLARE @LookAndFeel nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @LookAndFeel OUT, 'relationData.createdBy.personalSpace._expandable.lookAndFeel'
    DECLARE @Permissions nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Permissions OUT, 'relationData.createdBy.personalSpace._expandable.permissions'
    DECLARE @Icon nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Icon OUT, 'relationData.createdBy.personalSpace._expandable.icon'
    DECLARE @Description nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Description OUT, 'relationData.createdBy.personalSpace._expandable.description'
    DECLARE @Theme nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Theme OUT, 'relationData.createdBy.personalSpace._expandable.theme'
    DECLARE @History nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @History OUT, 'relationData.createdBy.personalSpace._expandable.history'
    DECLARE @Homepage nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Homepage OUT, 'relationData.createdBy.personalSpace._expandable.homepage'
    DECLARE @IconPath nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @IconPath OUT, 'relationData.createdBy.personalSpace.icon.path'
    DECLARE @IconWidth int
    EXEC sp_OAMethod @jResp, 'IntOf', @IconWidth OUT, 'relationData.createdBy.personalSpace.icon.width'
    DECLARE @IconHeight int
    EXEC sp_OAMethod @jResp, 'IntOf', @IconHeight OUT, 'relationData.createdBy.personalSpace.icon.height'
    DECLARE @IconIsDefault int
    EXEC sp_OAMethod @jResp, 'BoolOf', @IconIsDefault OUT, 'relationData.createdBy.personalSpace.icon.isDefault'
    DECLARE @PlainValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @PlainValue OUT, 'relationData.createdBy.personalSpace.description.plain.value'
    DECLARE @Representation nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Representation OUT, 'relationData.createdBy.personalSpace.description.plain.representation'
    DECLARE @ViewValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ViewValue OUT, 'relationData.createdBy.personalSpace.description.view.value'
    DECLARE @ViewRepresentation nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ViewRepresentation OUT, 'relationData.createdBy.personalSpace.description.view.representation'
    DECLARE @HomepageValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @HomepageValue OUT, 'relationData.createdBy.personalSpace.homepage.value'
    DECLARE @Start int
    EXEC sp_OAMethod @jResp, 'IntOf', @Start OUT, 'relationData.createdBy.personalSpace.metadata.labels.start'
    DECLARE @Limit int
    EXEC sp_OAMethod @jResp, 'IntOf', @Limit OUT, 'relationData.createdBy.personalSpace.metadata.labels.limit'
    DECLARE @Size int
    EXEC sp_OAMethod @jResp, 'IntOf', @Size OUT, 'relationData.createdBy.personalSpace.metadata.labels.size'
    DECLARE @RouteOverrideEnabled int
    EXEC sp_OAMethod @jResp, 'BoolOf', @RouteOverrideEnabled OUT, 'relationData.createdBy.personalSpace.settings.routeOverrideEnabled'
    DECLARE @Color nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Color OUT, 'relationData.createdBy.personalSpace.lookAndFeel.headings.color'
    DECLARE @LinksColor nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @LinksColor OUT, 'relationData.createdBy.personalSpace.lookAndFeel.links.color'
    DECLARE @HoverOrFocusValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @HoverOrFocusValue OUT, 'relationData.createdBy.personalSpace.lookAndFeel.menus.hoverOrFocus.value'
    DECLARE @ColorValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ColorValue OUT, 'relationData.createdBy.personalSpace.lookAndFeel.menus.color.value'
    DECLARE @BackgroundColorValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @BackgroundColorValue OUT, 'relationData.createdBy.personalSpace.lookAndFeel.header.backgroundColor.value'
    DECLARE @ButtonValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ButtonValue OUT, 'relationData.createdBy.personalSpace.lookAndFeel.header.button.value'
    DECLARE @PrimaryNavigationValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @PrimaryNavigationValue OUT, 'relationData.createdBy.personalSpace.lookAndFeel.header.primaryNavigation.value'
    DECLARE @SecondaryNavigationValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @SecondaryNavigationValue OUT, 'relationData.createdBy.personalSpace.lookAndFeel.header.secondaryNavigation.value'
    DECLARE @SearchValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @SearchValue OUT, 'relationData.createdBy.personalSpace.lookAndFeel.header.search.value'
    DECLARE @ScreenValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ScreenValue OUT, 'relationData.createdBy.personalSpace.lookAndFeel.content.screen.value'
    DECLARE @ContainerValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ContainerValue OUT, 'relationData.createdBy.personalSpace.lookAndFeel.content.container.value'
    DECLARE @HeaderValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @HeaderValue OUT, 'relationData.createdBy.personalSpace.lookAndFeel.content.header.value'
    DECLARE @BodyValue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @BodyValue OUT, 'relationData.createdBy.personalSpace.lookAndFeel.content.body.value'
    DECLARE @BordersAndDividersColor nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @BordersAndDividersColor OUT, 'relationData.createdBy.personalSpace.lookAndFeel.bordersAndDividers.color'
    DECLARE @CreatedDate nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @CreatedDate OUT, 'relationData.createdBy.personalSpace.history.createdDate'
    DECLARE @relationDataCreatedDate nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @relationDataCreatedDate OUT, 'relationData.createdDate'
    DECLARE @FriendlyCreatedDate nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @FriendlyCreatedDate OUT, 'relationData.friendlyCreatedDate'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'relationData.createdBy.operations'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @operation OUT, 'relationData.createdBy.operations[i].operation'
        EXEC sp_OAMethod @jResp, 'StringOf', @targetType OUT, 'relationData.createdBy.operations[i].targetType'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'relationData.createdBy.personalSpace.description.plain.embeddedContent'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'relationData.createdBy.personalSpace.description.plain.embeddedContent[i].value'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'relationData.createdBy.personalSpace.description.view.embeddedContent'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'relationData.createdBy.personalSpace.description.view.embeddedContent[i].value'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'relationData.createdBy.personalSpace.metadata.labels.results'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'relationData.createdBy.personalSpace.metadata.labels.results[i].value'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'relationData.createdBy.personalSpace.operations'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @operation OUT, 'relationData.createdBy.personalSpace.operations[i].operation'
        EXEC sp_OAMethod @jResp, 'StringOf', @targetType OUT, 'relationData.createdBy.personalSpace.operations[i].targetType'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'relationData.createdBy.personalSpace.permissions'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @v_expandableValue OUT, 'relationData.createdBy.personalSpace.permissions[i].subjects._expandable.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @UserValue OUT, 'relationData.createdBy.personalSpace.permissions[i].subjects.user.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @GroupValue OUT, 'relationData.createdBy.personalSpace.permissions[i].subjects.group.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @Operation OUT, 'relationData.createdBy.personalSpace.permissions[i].operation.operation'
        EXEC sp_OAMethod @jResp, 'StringOf', @TargetType OUT, 'relationData.createdBy.personalSpace.permissions[i].operation.targetType'
        EXEC sp_OAMethod @jResp, 'BoolOf', @anonymousAccess OUT, 'relationData.createdBy.personalSpace.permissions[i].anonymousAccess'
        EXEC sp_OAMethod @jResp, 'BoolOf', @unlicensedAccess OUT, 'relationData.createdBy.personalSpace.permissions[i].unlicensedAccess'
        SELECT @i = @i + 1
      END

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


END
GO

Curl Command

curl -X PUT
	-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>

Postman Collection Item JSON

{
  "name": "Create relationship",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "PUT",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "relation",
        ":relationName",
        "from",
        ":sourceType",
        ":sourceKey",
        "to",
        ":targetType",
        ":targetKey"
      ],
      "query": [
        {
          "key": "sourceStatus",
          "value": "<string>",
          "description": "The status of the source. This parameter is only used when the\n`sourceType` is 'content'."
        },
        {
          "key": "targetStatus",
          "value": "<string>",
          "description": "The status of the target. This parameter is only used when the\n`targetType` is 'content'."
        },
        {
          "key": "sourceVersion",
          "value": "<integer>",
          "description": "The version of the source. This parameter is only used when the\n`sourceType` is 'content' and the `sourceStatus` is 'historical'."
        },
        {
          "key": "targetVersion",
          "value": "<integer>",
          "description": "The version of the target. This parameter is only used when the\n`targetType` is 'content' and the `targetStatus` is 'historical'."
        }
      ],
      "variable": [
        {
          "key": "relationName",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The name of the relationship. This method supports the 'favourite'\n(i.e. 'save for later') relationship. You can also specify any other\nvalue for this parameter to create a custom relationship type."
        },
        {
          "key": "sourceType",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The source entity type of the relationship. This must be 'user', if\nthe `relationName` is 'favourite'."
        },
        {
          "key": "sourceKey",
          "value": "<string>",
          "type": "string",
          "description": "(Required) - The identifier for the source entity:\n\n- If `sourceType` is 'user', then specify either 'current' (logged-in\n  user) or the user key.\n- If `sourceType` is 'content', then specify the content ID.\n- If `sourceType` is 'space', then specify the space key."
        },
        {
          "key": "targetType",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The target entity type of the relationship. This must be 'space' or\n'content', if the `relationName` is 'favourite'."
        },
        {
          "key": "targetKey",
          "value": "<string>",
          "type": "string",
          "description": "(Required) - The identifier for the target entity:\n\n- If `sourceType` is 'user', then specify either 'current' (logged-in\n  user) or the user key.\n- If `sourceType` is 'content', then specify the content ID.\n- If `sourceType` is 'space', then specify the space key."
        }
      ]
    },
    "description": "Creates a relationship between two entities (user, space, content). The\n'favourite' relationship is supported by default, but you can use this method\nto create any type of relationship between two entities.\n\nFor example, the following method creates a 'sibling' relationship between\ntwo pieces of content:\n`GET https://your-domain.atlassian.net/wiki/rest/api/relation/sibling/from/content/123/to/content/456`\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\nPermission to access the Confluence site ('Can use' global permission)."
  },
  "response": [
    {
      "name": "Returned if the relationship is created.",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "relation",
            ":relationName",
            "from",
            ":sourceType",
            ":sourceKey",
            "to",
            ":targetType",
            ":targetKey"
          ],
          "query": [
            {
              "key": "sourceStatus",
              "value": "<string>"
            },
            {
              "key": "targetStatus",
              "value": "<string>"
            },
            {
              "key": "sourceVersion",
              "value": "<integer>"
            },
            {
              "key": "targetVersion",
              "value": "<integer>"
            }
          ],
          "variable": [
            {
              "key": "relationName"
            },
            {
              "key": "sourceType"
            },
            {
              "key": "sourceKey"
            },
            {
              "key": "targetType"
            },
            {
              "key": "targetKey"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"name\": \"laborum amet\",\n \"_expandable\": {\n  \"relationData\": \"minim do quis\",\n  \"source\": \"quis velit dolore ut\",\n  \"target\": \"sint fugiat id repreh\"\n },\n \"_links\": {},\n \"relationData\": {\n  \"createdBy\": {\n   \"type\": \"known\",\n   \"accountId\": \"est veniam nisi\",\n   \"accountType\": \"atlassian\",\n   \"email\": \"fugiat tempor est\",\n   \"publicName\": \"proident cillum adipisicing\",\n   \"profilePicture\": {\n    \"path\": \"incididunt dolore sit in eu\",\n    \"width\": 66665902,\n    \"height\": 7198703,\n    \"isDefault\": false\n   },\n   \"displayName\": \"mollit ex pariatur dolor\",\n   \"_expandable\": {\n    \"operations\": \"adipisicing in\",\n    \"details\": \"id minim sed\",\n    \"personalSpace\": \"Ut\"\n   },\n   \"_links\": {},\n   \"username\": \"proident ut incididunt consequat\",\n   \"userKey\": \"ipsum consequat sed ullamco aliquip\",\n   \"operations\": [\n    {\n     \"operation\": \"copy\",\n     \"targetType\": \"space\"\n    },\n    {\n     \"operation\": \"purge_version\",\n     \"targetType\": \"space\"\n    }\n   ],\n   \"details\": {\n    \"business\": {\n     \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n    },\n    \"personal\": {\n     \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n    }\n   },\n   \"personalSpace\": {\n    \"id\": 32251017,\n    \"key\": \"Excepteur do\",\n    \"name\": \"est velit non\",\n    \"type\": \"deserunt occaecat\",\n    \"status\": \"in commodo incididunt non\",\n    \"_expandable\": {\n     \"settings\": \"ut cillum quis in\",\n     \"metadata\": \"dolore minim\",\n     \"operations\": \"anim commodo amet\",\n     \"lookAndFeel\": \"dolore Lorem\",\n     \"permissions\": \"dolore anim\",\n     \"icon\": \"deserunt ex occaecat amet\",\n     \"description\": \"cillum nostrud sint\",\n     \"theme\": \"dolor id\",\n     \"history\": \"in fugiat eu esse\",\n     \"homepage\": \"et\"\n    },\n    \"_links\": {},\n    \"icon\": {\n     \"path\": \"laboris eiusmod Excepteur eu\",\n     \"width\": -89581460,\n     \"height\": -66835718,\n     \"isDefault\": true\n    },\n    \"description\": {\n     \"plain\": {\n      \"value\": \"ut eu reprehenderit\",\n      \"representation\": \"view\",\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\": \"reprehenderit\",\n      \"representation\": \"view\",\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\": 83305188,\n      \"limit\": 81363289,\n      \"size\": -91970205,\n      \"_links\": {}\n     }\n    },\n    \"operations\": [\n     {\n      \"operation\": \"purge\",\n      \"targetType\": \"comment\"\n     },\n     {\n      \"operation\": \"use\",\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\": \"purge_version\",\n       \"targetType\": \"page\"\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\": \"administer\",\n       \"targetType\": \"blogpost\"\n      },\n      \"anonymousAccess\": false,\n      \"unlicensedAccess\": false\n     }\n    ],\n    \"settings\": {\n     \"routeOverrideEnabled\": true,\n     \"_links\": {}\n    },\n    \"theme\": {},\n    \"lookAndFeel\": {\n     \"headings\": {\n      \"color\": \"fugiat irure nostrud\"\n     },\n     \"links\": {\n      \"color\": \"ad velit\"\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\": \"do in laborum\"\n     }\n    },\n    \"history\": {\n     \"createdDate\": \"1968-05-01T03:07:38.118Z\"\n    }\n   }\n  },\n  \"createdDate\": \"1955-09-27T16:15:59.770Z\",\n  \"friendlyCreatedDate\": \"reprehenderit quis\"\n },\n \"source\": {},\n \"target\": {}\n}"
    },
    {
      "name": "Returned if the user does not have permission to use Confluence.",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "relation",
            ":relationName",
            "from",
            ":sourceType",
            ":sourceKey",
            "to",
            ":targetType",
            ":targetKey"
          ],
          "query": [
            {
              "key": "sourceStatus",
              "value": "<string>"
            },
            {
              "key": "targetStatus",
              "value": "<string>"
            },
            {
              "key": "sourceVersion",
              "value": "<integer>"
            },
            {
              "key": "targetVersion",
              "value": "<integer>"
            }
          ],
          "variable": [
            {
              "key": "relationName"
            },
            {
              "key": "sourceType"
            },
            {
              "key": "sourceKey"
            },
            {
              "key": "targetType"
            },
            {
              "key": "targetKey"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if the user, space or content could not be found.",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "relation",
            ":relationName",
            "from",
            ":sourceType",
            ":sourceKey",
            "to",
            ":targetType",
            ":targetKey"
          ],
          "query": [
            {
              "key": "sourceStatus",
              "value": "<string>"
            },
            {
              "key": "targetStatus",
              "value": "<string>"
            },
            {
              "key": "sourceVersion",
              "value": "<integer>"
            },
            {
              "key": "targetVersion",
              "value": "<integer>"
            }
          ],
          "variable": [
            {
              "key": "relationName"
            },
            {
              "key": "sourceType"
            },
            {
              "key": "sourceKey"
            },
            {
              "key": "targetType"
            },
            {
              "key": "targetKey"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}