Chilkat Online Tools

BatchWrite SQL Server Example

Amazon Cloud Directory

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @sTmp0 nvarchar(max)
    -- This example requires the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @rest int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Rest', @rest OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    DECLARE @authAws int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.AuthAws', @authAws OUT

    EXEC sp_OASetProperty @authAws, 'AccessKey', 'AWS_ACCESS_KEY'
    EXEC sp_OASetProperty @authAws, 'SecretKey', 'AWS_SECRET_KEY'

    -- Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
    EXEC sp_OASetProperty @authAws, 'Region', 'us-west-2'
    EXEC sp_OASetProperty @authAws, 'ServiceName', 'clouddirectory'
    -- SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    EXEC sp_OAMethod @rest, 'SetAuthAws', @success OUT, @authAws

    -- URL: https://clouddirectory.us-west-2.amazonaws.com/
    -- Use the same region as specified above.
    EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'clouddirectory.us-west-2.amazonaws.com', 443, 1, 1
    IF @success <> 1
      BEGIN

        EXEC sp_OAGetProperty @rest, 'ConnectFailReason', @iTmp0 OUT
        PRINT 'ConnectFailReason: ' + @iTmp0
        EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @rest
        EXEC @hr = sp_OADestroy @authAws
        RETURN
      END

    -- The following code creates the JSON request body.
    -- The JSON created by this code is shown below.

    -- Use this online tool to generate code from sample JSON:
    -- Generate Code to Create JSON

    DECLARE @json int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AddFacetToObject.ObjectAttributeList[0].Key.FacetName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AddFacetToObject.ObjectAttributeList[0].Key.Name', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AddFacetToObject.ObjectAttributeList[0].Key.SchemaArn', 'string'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].AddFacetToObject.ObjectAttributeList[0].Value.BinaryValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].AddFacetToObject.ObjectAttributeList[0].Value.BooleanValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].AddFacetToObject.ObjectAttributeList[0].Value.DatetimeValue', 123
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AddFacetToObject.ObjectAttributeList[0].Value.NumberValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AddFacetToObject.ObjectAttributeList[0].Value.StringValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AddFacetToObject.ObjectReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AddFacetToObject.SchemaFacet.FacetName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AddFacetToObject.SchemaFacet.SchemaArn', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachObject.ChildReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachObject.LinkName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachObject.ParentReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachPolicy.ObjectReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachPolicy.PolicyReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachToIndex.IndexReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachToIndex.TargetReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachTypedLink.Attributes[0].AttributeName', 'string'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].AttachTypedLink.Attributes[0].Value.BinaryValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].AttachTypedLink.Attributes[0].Value.BooleanValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].AttachTypedLink.Attributes[0].Value.DatetimeValue', 123
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachTypedLink.Attributes[0].Value.NumberValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachTypedLink.Attributes[0].Value.StringValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachTypedLink.SourceObjectReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachTypedLink.TargetObjectReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachTypedLink.TypedLinkFacet.SchemaArn', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].AttachTypedLink.TypedLinkFacet.TypedLinkName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateIndex.BatchReferenceName', 'string'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].CreateIndex.IsUnique', 123
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateIndex.LinkName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateIndex.OrderedIndexedAttributeList[0].FacetName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateIndex.OrderedIndexedAttributeList[0].Name', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateIndex.OrderedIndexedAttributeList[0].SchemaArn', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateIndex.ParentReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateObject.BatchReferenceName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateObject.LinkName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateObject.ObjectAttributeList[0].Key.FacetName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateObject.ObjectAttributeList[0].Key.Name', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateObject.ObjectAttributeList[0].Key.SchemaArn', 'string'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].CreateObject.ObjectAttributeList[0].Value.BinaryValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].CreateObject.ObjectAttributeList[0].Value.BooleanValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].CreateObject.ObjectAttributeList[0].Value.DatetimeValue', 123
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateObject.ObjectAttributeList[0].Value.NumberValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateObject.ObjectAttributeList[0].Value.StringValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateObject.ParentReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateObject.SchemaFacet[0].FacetName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].CreateObject.SchemaFacet[0].SchemaArn', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DeleteObject.ObjectReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachFromIndex.IndexReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachFromIndex.TargetReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachObject.BatchReferenceName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachObject.LinkName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachObject.ParentReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachPolicy.ObjectReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachPolicy.PolicyReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[0].AttributeName', 'string'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].DetachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[0].Value.BinaryValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].DetachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[0].Value.BooleanValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].DetachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[0].Value.DatetimeValue', 123
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[0].Value.NumberValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[0].Value.StringValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachTypedLink.TypedLinkSpecifier.SourceObjectReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachTypedLink.TypedLinkSpecifier.TargetObjectReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachTypedLink.TypedLinkSpecifier.TypedLinkFacet.SchemaArn', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].DetachTypedLink.TypedLinkSpecifier.TypedLinkFacet.TypedLinkName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].RemoveFacetFromObject.ObjectReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].RemoveFacetFromObject.SchemaFacet.FacetName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].RemoveFacetFromObject.SchemaFacet.SchemaArn', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.AttributeUpdates[0].AttributeAction.AttributeActionType', 'string'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].UpdateLinkAttributes.AttributeUpdates[0].AttributeAction.AttributeUpdateValue.BinaryValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].UpdateLinkAttributes.AttributeUpdates[0].AttributeAction.AttributeUpdateValue.BooleanValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].UpdateLinkAttributes.AttributeUpdates[0].AttributeAction.AttributeUpdateValue.DatetimeValue', 123
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.AttributeUpdates[0].AttributeAction.AttributeUpdateValue.NumberValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.AttributeUpdates[0].AttributeAction.AttributeUpdateValue.StringValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.AttributeUpdates[0].AttributeKey.FacetName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.AttributeUpdates[0].AttributeKey.Name', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.AttributeUpdates[0].AttributeKey.SchemaArn', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.TypedLinkSpecifier.IdentityAttributeValues[0].AttributeName', 'string'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].UpdateLinkAttributes.TypedLinkSpecifier.IdentityAttributeValues[0].Value.BinaryValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].UpdateLinkAttributes.TypedLinkSpecifier.IdentityAttributeValues[0].Value.BooleanValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].UpdateLinkAttributes.TypedLinkSpecifier.IdentityAttributeValues[0].Value.DatetimeValue', 123
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.TypedLinkSpecifier.IdentityAttributeValues[0].Value.NumberValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.TypedLinkSpecifier.IdentityAttributeValues[0].Value.StringValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.TypedLinkSpecifier.SourceObjectReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.TypedLinkSpecifier.TargetObjectReference.Selector', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.TypedLinkSpecifier.TypedLinkFacet.SchemaArn', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateLinkAttributes.TypedLinkSpecifier.TypedLinkFacet.TypedLinkName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateObjectAttributes.AttributeUpdates[0].ObjectAttributeAction.ObjectAttributeActionType', 'string'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].UpdateObjectAttributes.AttributeUpdates[0].ObjectAttributeAction.ObjectAttributeUpdateValue.BinaryValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].UpdateObjectAttributes.AttributeUpdates[0].ObjectAttributeAction.ObjectAttributeUpdateValue.BooleanValue', 123
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'Operations[0].UpdateObjectAttributes.AttributeUpdates[0].ObjectAttributeAction.ObjectAttributeUpdateValue.DatetimeValue', 123
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateObjectAttributes.AttributeUpdates[0].ObjectAttributeAction.ObjectAttributeUpdateValue.NumberValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateObjectAttributes.AttributeUpdates[0].ObjectAttributeAction.ObjectAttributeUpdateValue.StringValue', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateObjectAttributes.AttributeUpdates[0].ObjectAttributeKey.FacetName', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateObjectAttributes.AttributeUpdates[0].ObjectAttributeKey.Name', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateObjectAttributes.AttributeUpdates[0].ObjectAttributeKey.SchemaArn', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Operations[0].UpdateObjectAttributes.ObjectReference.Selector', 'string'

    -- The JSON request body created by the above code:

    -- {
    --   "Operations": [
    --     {
    --       "AddFacetToObject": {
    --         "ObjectAttributeList": [
    --           {
    --             "Key": {
    --               "FacetName": "string",
    --               "Name": "string",
    --               "SchemaArn": "string"
    --             },
    --             "Value": {
    --               "BinaryValue": blob,
    --               "BooleanValue": boolean,
    --               "DatetimeValue": number,
    --               "NumberValue": "string",
    --               "StringValue": "string"
    --             }
    --           }
    --         ],
    --         "ObjectReference": {
    --           "Selector": "string"
    --         },
    --         "SchemaFacet": {
    --           "FacetName": "string",
    --           "SchemaArn": "string"
    --         }
    --       },
    --       "AttachObject": {
    --         "ChildReference": {
    --           "Selector": "string"
    --         },
    --         "LinkName": "string",
    --         "ParentReference": {
    --           "Selector": "string"
    --         }
    --       },
    --       "AttachPolicy": {
    --         "ObjectReference": {
    --           "Selector": "string"
    --         },
    --         "PolicyReference": {
    --           "Selector": "string"
    --         }
    --       },
    --       "AttachToIndex": {
    --         "IndexReference": {
    --           "Selector": "string"
    --         },
    --         "TargetReference": {
    --           "Selector": "string"
    --         }
    --       },
    --       "AttachTypedLink": {
    --         "Attributes": [
    --           {
    --             "AttributeName": "string",
    --             "Value": {
    --               "BinaryValue": blob,
    --               "BooleanValue": boolean,
    --               "DatetimeValue": number,
    --               "NumberValue": "string",
    --               "StringValue": "string"
    --             }
    --           }
    --         ],
    --         "SourceObjectReference": {
    --           "Selector": "string"
    --         },
    --         "TargetObjectReference": {
    --           "Selector": "string"
    --         },
    --         "TypedLinkFacet": {
    --           "SchemaArn": "string",
    --           "TypedLinkName": "string"
    --         }
    --       },
    --       "CreateIndex": {
    --         "BatchReferenceName": "string",
    --         "IsUnique": boolean,
    --         "LinkName": "string",
    --         "OrderedIndexedAttributeList": [
    --           {
    --             "FacetName": "string",
    --             "Name": "string",
    --             "SchemaArn": "string"
    --           }
    --         ],
    --         "ParentReference": {
    --           "Selector": "string"
    --         }
    --       },
    --       "CreateObject": {
    --         "BatchReferenceName": "string",
    --         "LinkName": "string",
    --         "ObjectAttributeList": [
    --           {
    --             "Key": {
    --               "FacetName": "string",
    --               "Name": "string",
    --               "SchemaArn": "string"
    --             },
    --             "Value": {
    --               "BinaryValue": blob,
    --               "BooleanValue": boolean,
    --               "DatetimeValue": number,
    --               "NumberValue": "string",
    --               "StringValue": "string"
    --             }
    --           }
    --         ],
    --         "ParentReference": {
    --           "Selector": "string"
    --         },
    --         "SchemaFacet": [
    --           {
    --             "FacetName": "string",
    --             "SchemaArn": "string"
    --           }
    --         ]
    --       },
    --       "DeleteObject": {
    --         "ObjectReference": {
    --           "Selector": "string"
    --         }
    --       },
    --       "DetachFromIndex": {
    --         "IndexReference": {
    --           "Selector": "string"
    --         },
    --         "TargetReference": {
    --           "Selector": "string"
    --         }
    --       },
    --       "DetachObject": {
    --         "BatchReferenceName": "string",
    --         "LinkName": "string",
    --         "ParentReference": {
    --           "Selector": "string"
    --         }
    --       },
    --       "DetachPolicy": {
    --         "ObjectReference": {
    --           "Selector": "string"
    --         },
    --         "PolicyReference": {
    --           "Selector": "string"
    --         }
    --       },
    --       "DetachTypedLink": {
    --         "TypedLinkSpecifier": {
    --           "IdentityAttributeValues": [
    --             {
    --               "AttributeName": "string",
    --               "Value": {
    --                 "BinaryValue": blob,
    --                 "BooleanValue": boolean,
    --                 "DatetimeValue": number,
    --                 "NumberValue": "string",
    --                 "StringValue": "string"
    --               }
    --             }
    --           ],
    --           "SourceObjectReference": {
    --             "Selector": "string"
    --           },
    --           "TargetObjectReference": {
    --             "Selector": "string"
    --           },
    --           "TypedLinkFacet": {
    --             "SchemaArn": "string",
    --             "TypedLinkName": "string"
    --           }
    --         }
    --       },
    --       "RemoveFacetFromObject": {
    --         "ObjectReference": {
    --           "Selector": "string"
    --         },
    --         "SchemaFacet": {
    --           "FacetName": "string",
    --           "SchemaArn": "string"
    --         }
    --       },
    --       "UpdateLinkAttributes": {
    --         "AttributeUpdates": [
    --           {
    --             "AttributeAction": {
    --               "AttributeActionType": "string",
    --               "AttributeUpdateValue": {
    --                 "BinaryValue": blob,
    --                 "BooleanValue": boolean,
    --                 "DatetimeValue": number,
    --                 "NumberValue": "string",
    --                 "StringValue": "string"
    --               }
    --             },
    --             "AttributeKey": {
    --               "FacetName": "string",
    --               "Name": "string",
    --               "SchemaArn": "string"
    --             }
    --           }
    --         ],
    --         "TypedLinkSpecifier": {
    --           "IdentityAttributeValues": [
    --             {
    --               "AttributeName": "string",
    --               "Value": {
    --                 "BinaryValue": blob,
    --                 "BooleanValue": boolean,
    --                 "DatetimeValue": number,
    --                 "NumberValue": "string",
    --                 "StringValue": "string"
    --               }
    --             }
    --           ],
    --           "SourceObjectReference": {
    --             "Selector": "string"
    --           },
    --           "TargetObjectReference": {
    --             "Selector": "string"
    --           },
    --           "TypedLinkFacet": {
    --             "SchemaArn": "string",
    --             "TypedLinkName": "string"
    --           }
    --         }
    --       },
    --       "UpdateObjectAttributes": {
    --         "AttributeUpdates": [
    --           {
    --             "ObjectAttributeAction": {
    --               "ObjectAttributeActionType": "string",
    --               "ObjectAttributeUpdateValue": {
    --                 "BinaryValue": blob,
    --                 "BooleanValue": boolean,
    --                 "DatetimeValue": number,
    --                 "NumberValue": "string",
    --                 "StringValue": "string"
    --               }
    --             },
    --             "ObjectAttributeKey": {
    --               "FacetName": "string",
    --               "Name": "string",
    --               "SchemaArn": "string"
    --             }
    --           }
    --         ],
    --         "ObjectReference": {
    --           "Selector": "string"
    --         }
    --       }
    --     }
    --   ]
    -- }

    EXEC sp_OAMethod @rest, 'AddHeader', @success OUT, 'Content-Type', 'application/x-amz-json-1.1'
    EXEC sp_OAMethod @rest, 'AddHeader', @success OUT, 'X-Amz-Target', 'BatchWrite'

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

    EXEC sp_OAMethod @json, 'EmitSb', @success OUT, @sbRequestBody
    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @rest, 'FullRequestSb', @success OUT, 'PUT', '/amazonclouddirectory/2017-01-11/batchwrite', @sbRequestBody, @sbResponseBody
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @rest
        EXEC @hr = sp_OADestroy @authAws
        EXEC @hr = sp_OADestroy @json
        EXEC @hr = sp_OADestroy @sbRequestBody
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END
    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @respStatusCode OUT

    PRINT 'response status code = ' + @respStatusCode
    IF @respStatusCode <> 200
      BEGIN

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

        PRINT 'Response Body:'
        EXEC sp_OAMethod @sbResponseBody, 'GetAsString', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @rest
        EXEC @hr = sp_OADestroy @authAws
        EXEC @hr = sp_OADestroy @json
        EXEC @hr = sp_OADestroy @sbRequestBody
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END

    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody

    -- The following code parses the JSON response.
    -- A sample JSON response is shown below the sample code.

    -- Use this online tool to generate parsing code from sample JSON:
    -- Generate Parsing Code from JSON

    DECLARE @AttachedObjectIdentifier nvarchar(max)

    DECLARE @AttachToIndexAttachedObjectIdentifier nvarchar(max)

    DECLARE @Selector nvarchar(max)

    DECLARE @TargetObjectReferenceSelector nvarchar(max)

    DECLARE @SchemaArn nvarchar(max)

    DECLARE @TypedLinkName nvarchar(max)

    DECLARE @ObjectIdentifier nvarchar(max)

    DECLARE @CreateObjectObjectIdentifier nvarchar(max)

    DECLARE @DetachedObjectIdentifier nvarchar(max)

    DECLARE @DetachObjectDetachedObjectIdentifier nvarchar(max)

    DECLARE @UpdateObjectAttributesObjectIdentifier nvarchar(max)

    DECLARE @j int

    DECLARE @count_j int

    DECLARE @AttributeName nvarchar(max)

    DECLARE @BinaryValue int

    DECLARE @BooleanValue int

    DECLARE @DatetimeValue int

    DECLARE @NumberValue nvarchar(max)

    DECLARE @StringValue nvarchar(max)

    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'Responses'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @AttachedObjectIdentifier OUT, 'Responses[i].AttachObject.attachedObjectIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @AttachToIndexAttachedObjectIdentifier OUT, 'Responses[i].AttachToIndex.AttachedObjectIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @Selector OUT, 'Responses[i].AttachTypedLink.TypedLinkSpecifier.SourceObjectReference.Selector'
        EXEC sp_OAMethod @jResp, 'StringOf', @TargetObjectReferenceSelector OUT, 'Responses[i].AttachTypedLink.TypedLinkSpecifier.TargetObjectReference.Selector'
        EXEC sp_OAMethod @jResp, 'StringOf', @SchemaArn OUT, 'Responses[i].AttachTypedLink.TypedLinkSpecifier.TypedLinkFacet.SchemaArn'
        EXEC sp_OAMethod @jResp, 'StringOf', @TypedLinkName OUT, 'Responses[i].AttachTypedLink.TypedLinkSpecifier.TypedLinkFacet.TypedLinkName'
        EXEC sp_OAMethod @jResp, 'StringOf', @ObjectIdentifier OUT, 'Responses[i].CreateIndex.ObjectIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @CreateObjectObjectIdentifier OUT, 'Responses[i].CreateObject.ObjectIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @DetachedObjectIdentifier OUT, 'Responses[i].DetachFromIndex.DetachedObjectIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @DetachObjectDetachedObjectIdentifier OUT, 'Responses[i].DetachObject.detachedObjectIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @UpdateObjectAttributesObjectIdentifier OUT, 'Responses[i].UpdateObjectAttributes.ObjectIdentifier'
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Responses[i].AttachTypedLink.TypedLinkSpecifier.IdentityAttributeValues'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @AttributeName OUT, 'Responses[i].AttachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[j].AttributeName'
            EXEC sp_OAMethod @jResp, 'IntOf', @BinaryValue OUT, 'Responses[i].AttachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[j].Value.BinaryValue'
            EXEC sp_OAMethod @jResp, 'IntOf', @BooleanValue OUT, 'Responses[i].AttachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[j].Value.BooleanValue'
            EXEC sp_OAMethod @jResp, 'IntOf', @DatetimeValue OUT, 'Responses[i].AttachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[j].Value.DatetimeValue'
            EXEC sp_OAMethod @jResp, 'StringOf', @NumberValue OUT, 'Responses[i].AttachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[j].Value.NumberValue'
            EXEC sp_OAMethod @jResp, 'StringOf', @StringValue OUT, 'Responses[i].AttachTypedLink.TypedLinkSpecifier.IdentityAttributeValues[j].Value.StringValue'
            SELECT @j = @j + 1
          END
        SELECT @i = @i + 1
      END

    -- A sample JSON response body parsed by the above code:

    -- {
    --   "Responses": [
    --     {
    --       "AddFacetToObject": {},
    --       "AttachObject": {
    --         "attachedObjectIdentifier": "string"
    --       },
    --       "AttachPolicy": {},
    --       "AttachToIndex": {
    --         "AttachedObjectIdentifier": "string"
    --       },
    --       "AttachTypedLink": {
    --         "TypedLinkSpecifier": {
    --           "IdentityAttributeValues": [
    --             {
    --               "AttributeName": "string",
    --               "Value": {
    --                 "BinaryValue": blob,
    --                 "BooleanValue": boolean,
    --                 "DatetimeValue": number,
    --                 "NumberValue": "string",
    --                 "StringValue": "string"
    --               }
    --             }
    --           ],
    --           "SourceObjectReference": {
    --             "Selector": "string"
    --           },
    --           "TargetObjectReference": {
    --             "Selector": "string"
    --           },
    --           "TypedLinkFacet": {
    --             "SchemaArn": "string",
    --             "TypedLinkName": "string"
    --           }
    --         }
    --       },
    --       "CreateIndex": {
    --         "ObjectIdentifier": "string"
    --       },
    --       "CreateObject": {
    --         "ObjectIdentifier": "string"
    --       },
    --       "DeleteObject": {},
    --       "DetachFromIndex": {
    --         "DetachedObjectIdentifier": "string"
    --       },
    --       "DetachObject": {
    --         "detachedObjectIdentifier": "string"
    --       },
    --       "DetachPolicy": {},
    --       "DetachTypedLink": {},
    --       "RemoveFacetFromObject": {},
    --       "UpdateLinkAttributes": {},
    --       "UpdateObjectAttributes": {
    --         "ObjectIdentifier": "string"
    --       }
    --     }
    --   ]
    -- }

    EXEC @hr = sp_OADestroy @rest
    EXEC @hr = sp_OADestroy @authAws
    EXEC @hr = sp_OADestroy @json
    EXEC @hr = sp_OADestroy @sbRequestBody
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO