Sample code for 30+ languages & platforms
SQL Server

OneDrive -- List Root Directory

See more OneDrive Examples

This gets the collection of DriveItem children of the root DriveItem. In OneDrive, a driveItem resource represents a file, folder, or other item stored in a drive. All file system objects in OneDriveare returned as driveItem resources (which are JSON objects).

This example returns the collection of child DriveItems for the root DriveItem.

Note: This example requires Chilkat v9.5.0.97 or greater.

Chilkat SQL Server Downloads

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

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

    -- This example uses the OAuth client credentials flow.
    -- See How to Create an Azure App Registration for OAuth 2.0 Client Credentials

    -- Use your client ID, client secret, and tenant ID in the following lines
    DECLARE @json int
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'client_id', '2871da2c-8176-4b7f-869b-2311aa82e743'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'client_secret', '2hu9Q~r5QuryUcEkNbg1btLtnfU1VUXzhSCG6brH'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'scope', 'https://graph.microsoft.com/.default'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'token_endpoint', 'https://login.microsoftonline.com/114d7ed6-71bf-4dbe-a866-748364121bf2/oauth2/v2.0/token'

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT

    EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT
    EXEC sp_OASetProperty @http, 'AuthToken', @sTmp0

    -- Sends the following GET request:
    -- GET https://graph.microsoft.com/v1.0/users/{user-id}/drive/items/{item-id}/children

    -- Use your specific Id instead of what we're using here:
    EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'userId', '4fe732c3-322e-4a6b-b729-2fd1eb5c6104'
    EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'itemId', 'root'

    DECLARE @resp nvarchar(4000)
    EXEC sp_OAMethod @http, 'QuickGetStr', @resp OUT, 'https://graph.microsoft.com/v1.0/users/{$userId}/drive/items/{$itemId}/children'
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 <> 1
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @json
        EXEC @hr = sp_OADestroy @http
        RETURN
      END

    -- The response should be JSON.
    EXEC sp_OASetProperty @json, 'EmitCompact', 0
    EXEC sp_OAMethod @json, 'Load', @success OUT, @resp

    -- A successful response should return a status code of 200.
    EXEC sp_OAGetProperty @http, 'LastStatus', @iTmp0 OUT
    IF @iTmp0 <> 200
      BEGIN
        EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT
        PRINT @sTmp0

        EXEC sp_OAGetProperty @http, 'LastStatus', @iTmp0 OUT
        PRINT 'Response status = ' + @iTmp0
        EXEC @hr = sp_OADestroy @json
        EXEC @hr = sp_OADestroy @http
        RETURN
      END

    EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    -- See the sample JSON response and output below..

    DECLARE @lastMod int
    EXEC @hr = sp_OACreate 'Chilkat.CkDateTime', @lastMod OUT

    DECLARE @photoTaken int
    EXEC @hr = sp_OACreate 'Chilkat.CkDateTime', @photoTaken OUT

    -- Iterate over the DriveItems in the JSON response:
    -- (I tested this example with a root that contains a several folders,
    -- a JPG image file, an XML file, and a WAV audio file.)
    DECLARE @i int
    SELECT @i = 0
    DECLARE @numItems int
    EXEC sp_OAMethod @json, 'SizeOfArray', @numItems OUT, 'value'
    WHILE @i < @numItems
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i

        PRINT '-- DriveItem ' + @i + 1

        EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'value[i].id'
        PRINT 'id: ' + @sTmp0

        EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'value[i].name'
        PRINT 'name: ' + @sTmp0

        EXEC sp_OAMethod @json, 'IntOf', @iTmp0 OUT, 'value[i].size'
        PRINT 'size: ' + @iTmp0

        -- Get the lastModifiedDateTime
        EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'value[i].fileSystemInfo.lastModifiedDateTime'
        EXEC sp_OAMethod @lastMod, 'SetFromTimestamp', @success OUT, @sTmp0

        -- Is this a folder?
        EXEC sp_OAMethod @json, 'HasMember', @iTmp0 OUT, 'value[i].folder'
        IF @iTmp0 = 1
          BEGIN

            EXEC sp_OAMethod @json, 'IntOf', @iTmp0 OUT, 'value[i].folder.childCount'

            PRINT 'This is a folder with ' + @iTmp0 + ' children'
          END
        EXEC sp_OAMethod @json, 'HasMember', @iTmp0 OUT, 'value[i].file'
        IF @iTmp0 = 1
          BEGIN

            PRINT 'This is a file.'

            EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'value[i].file.hashes.sha1Hash'
            PRINT 'SHA1 hash: ' + @sTmp0

            EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'value[i].mimeType'
            PRINT 'mimeType: ' + @sTmp0
          END
        EXEC sp_OAMethod @json, 'HasMember', @iTmp0 OUT, 'value[i].image'
        IF @iTmp0 = 1
          BEGIN

            PRINT 'This is an image.'

            EXEC sp_OAMethod @json, 'IntOf', @iTmp0 OUT, 'value[i].image.height'
            PRINT 'height: ' + @iTmp0

            EXEC sp_OAMethod @json, 'IntOf', @iTmp0 OUT, 'value[i].image.width'
            PRINT 'width: ' + @iTmp0
          END
        EXEC sp_OAMethod @json, 'HasMember', @iTmp0 OUT, 'value[i].photo'
        IF @iTmp0 = 1
          BEGIN

            PRINT 'This is a photo.'
            EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'value[i].photo.takenDateTime'
            EXEC sp_OAMethod @photoTaken, 'SetFromTimestamp', @success OUT, @sTmp0

            EXEC sp_OAMethod @photoTaken, 'GetAsRfc822', @sTmp0 OUT, 1
            PRINT 'photo taken on ' + @sTmp0
          END
        EXEC sp_OAMethod @json, 'HasMember', @iTmp0 OUT, 'value[i].audio'
        IF @iTmp0 = 1
          BEGIN

            PRINT 'This is an audio file.'

            EXEC sp_OAMethod @json, 'IntOf', @iTmp0 OUT, 'value[i].audio.duration'
            PRINT 'duration: ' + @iTmp0
          END

        SELECT @i = @i + 1
      END

    -- The output for the above loop:

    -- -- DriveItem 1
    -- id: 3A33FCEB9B74CC15!187
    -- name: Documents
    -- size: 4452847
    -- This is a folder with 8 children
    -- -- DriveItem 2
    -- id: 3A33FCEB9B74CC15!4114
    -- name: Downloads
    -- size: 18240001
    -- This is a folder with 6 children
    -- -- DriveItem 3
    -- id: 3A33FCEB9B74CC15!4407
    -- name: lots-of-files
    -- size: 7542
    -- This is a folder with 450 children
    -- -- DriveItem 4
    -- id: 3A33FCEB9B74CC15!4858
    -- name: Misc
    -- size: 819922938
    -- This is a folder with 6 children
    -- -- DriveItem 5
    -- id: 3A33FCEB9B74CC15!185
    -- name: Pictures
    -- size: 0
    -- This is a folder with 3 children
    -- -- DriveItem 6
    -- id: 3A33FCEB9B74CC15!186
    -- name: Public
    -- size: 0
    -- This is a folder with 0 children
    -- -- DriveItem 7
    -- id: 3A33FCEB9B74CC15!4860
    -- name: hamlet.xml
    -- size: 279658
    -- This is a file.
    -- SHA1 hash: C6AD0095E07141C97A3C6B85778602AD883F5500
    -- mimeType: 
    -- -- DriveItem 8
    -- id: 3A33FCEB9B74CC15!4861
    -- name: msg_123_abc.wav
    -- size: 155564
    -- This is a file.
    -- SHA1 hash: 1F51ADBDAADEAABC2D588C2A795AE86758525984
    -- mimeType: 
    -- This is an audio file.
    -- duration: 9720
    -- -- DriveItem 9
    -- id: 3A33FCEB9B74CC15!4859
    -- name: penguins.jpg
    -- size: 777835
    -- This is a file.
    -- SHA1 hash: DF7BE9DC4F467187783ACA68C7CE98E4DF2172D0
    -- mimeType: 
    -- This is an image.
    -- height: 768
    -- width: 1024
    -- This is a photo.
    -- photo taken on Sun, 17 Feb 2008 23:07:31 -0600
    -- 

    -- -------------------------------------------------------
    -- This is the JSON response when this example was tested:

    -- {
    --   "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('me')/drive/root/children",
    --   "value": [
    --     {
    --       "createdBy": {
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         }
    --       },
    --       "createdDateTime": "2013-06-12T19:49:08.367Z",
    --       "cTag": "adDozQTMzRkNFQjlCNzRDQzE1ITE4Ny42MzYyODA2Nzc4MjI3MzAwMDA",
    --       "eTag": "aM0EzM0ZDRUI5Qjc0Q0MxNSExODcuMA",
    --       "id": "3A33FCEB9B74CC15!187",
    --       "lastModifiedBy": {
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         }
    --       },
    --       "lastModifiedDateTime": "2017-04-17T23:16:22.273Z",
    --       "name": "Documents",
    --       "parentReference": {
    --         "driveId": "3a33fceb9b74cc15",
    --         "id": "3A33FCEB9B74CC15!184",
    --         "path": "/drive/root:"
    --       },
    --       "size": 4452847,
    --       "webUrl": "https://1drv.ms/f/s!ABXMdJvr_DM6gTs",
    --       "fileSystemInfo": {
    --         "createdDateTime": "2013-06-12T19:49:08.366Z",
    --         "lastModifiedDateTime": "2013-06-12T19:49:08.367Z"
    --       },
    --       "folder": {
    --         "childCount": 8
    --       },
    --       "specialFolder": {
    --         "name": "documents"
    --       }
    --     },
    --     {
    --       "createdBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "createdDateTime": "2016-12-07T14:02:22.417Z",
    --       "cTag": "adDozQTMzRkNFQjlCNzRDQzE1ITQxMTQuNjM2MjQzMzEyODEwMjAwMDAw",
    --       "eTag": "aM0EzM0ZDRUI5Qjc0Q0MxNSE0MTE0LjE",
    --       "id": "3A33FCEB9B74CC15!4114",
    --       "lastModifiedBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "lastModifiedDateTime": "2017-03-05T17:21:21.02Z",
    --       "name": "Downloads",
    --       "parentReference": {
    --         "driveId": "3a33fceb9b74cc15",
    --         "id": "3A33FCEB9B74CC15!184",
    --         "path": "/drive/root:"
    --       },
    --       "size": 18240001,
    --       "webUrl": "https://1drv.ms/f/s!ABXMdJvr_DM6oBI",
    --       "fileSystemInfo": {
    --         "createdDateTime": "2016-12-07T14:02:09Z",
    --         "lastModifiedDateTime": "2016-12-07T14:02:09Z"
    --       },
    --       "folder": {
    --         "childCount": 6
    --       }
    --     },
    --     {
    --       "createdBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "createdDateTime": "2017-06-02T02:14:59.797Z",
    --       "cTag": "adDozQTMzRkNFQjlCNzRDQzE1ITQ0MDcuNjM2MzE5NjY2MDIzNDcwMDAw",
    --       "eTag": "aM0EzM0ZDRUI5Qjc0Q0MxNSE0NDA3LjA",
    --       "id": "3A33FCEB9B74CC15!4407",
    --       "lastModifiedBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "lastModifiedDateTime": "2017-06-02T02:16:42.347Z",
    --       "name": "lots-of-files",
    --       "parentReference": {
    --         "driveId": "3a33fceb9b74cc15",
    --         "id": "3A33FCEB9B74CC15!184",
    --         "path": "/drive/root:"
    --       },
    --       "size": 7542,
    --       "webUrl": "https://1drv.ms/f/s!ABXMdJvr_DM6ojc",
    --       "fileSystemInfo": {
    --         "createdDateTime": "2017-06-02T02:13:11Z",
    --         "lastModifiedDateTime": "2017-06-02T02:14:54Z"
    --       },
    --       "folder": {
    --         "childCount": 450
    --       }
    --     },
    --     {
    --       "createdBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "createdDateTime": "2017-06-02T19:06:10.293Z",
    --       "cTag": "adDozQTMzRkNFQjlCNzRDQzE1ITQ4NTguNjM2MzIwMjcxOTAxNDcwMDAw",
    --       "eTag": "aM0EzM0ZDRUI5Qjc0Q0MxNSE0ODU4LjA",
    --       "id": "3A33FCEB9B74CC15!4858",
    --       "lastModifiedBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "lastModifiedDateTime": "2017-06-02T19:06:30.147Z",
    --       "name": "Misc",
    --       "parentReference": {
    --         "driveId": "3a33fceb9b74cc15",
    --         "id": "3A33FCEB9B74CC15!184",
    --         "path": "/drive/root:"
    --       },
    --       "size": 819922938,
    --       "webUrl": "https://1drv.ms/f/s!ABXMdJvr_DM6pXo",
    --       "fileSystemInfo": {
    --         "createdDateTime": "2017-06-02T19:06:02Z",
    --         "lastModifiedDateTime": "2017-06-02T19:06:02Z"
    --       },
    --       "folder": {
    --         "childCount": 6
    --       }
    --     },
    --     {
    --       "createdBy": {
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         }
    --       },
    --       "createdDateTime": "2013-06-12T19:49:08.123Z",
    --       "cTag": "adDozQTMzRkNFQjlCNzRDQzE1ITE4NS42MzYxNDU5MzkxMDcyMDAwMDA",
    --       "eTag": "aM0EzM0ZDRUI5Qjc0Q0MxNSExODUuMA",
    --       "id": "3A33FCEB9B74CC15!185",
    --       "lastModifiedBy": {
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         }
    --       },
    --       "lastModifiedDateTime": "2016-11-13T00:31:50.72Z",
    --       "name": "Pictures",
    --       "parentReference": {
    --         "driveId": "3a33fceb9b74cc15",
    --         "id": "3A33FCEB9B74CC15!184",
    --         "path": "/drive/root:"
    --       },
    --       "size": 0,
    --       "webUrl": "https://1drv.ms/f/s!ABXMdJvr_DM6gTk",
    --       "fileSystemInfo": {
    --         "createdDateTime": "2013-06-12T19:49:08.123Z",
    --         "lastModifiedDateTime": "2013-06-12T19:49:08.123Z"
    --       },
    --       "folder": {
    --         "childCount": 3
    --       },
    --       "specialFolder": {
    --         "name": "photos"
    --       }
    --     },
    --     {
    --       "createdBy": {
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         }
    --       },
    --       "createdDateTime": "2013-06-12T19:49:08.183Z",
    --       "cTag": "adDozQTMzRkNFQjlCNzRDQzE1ITE4Ni42MzUwNjY2MzM0ODMwMzAwMDA",
    --       "eTag": "aM0EzM0ZDRUI5Qjc0Q0MxNSExODYuMQ",
    --       "id": "3A33FCEB9B74CC15!186",
    --       "lastModifiedBy": {
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         }
    --       },
    --       "lastModifiedDateTime": "2013-06-12T19:49:08.303Z",
    --       "name": "Public",
    --       "parentReference": {
    --         "driveId": "3a33fceb9b74cc15",
    --         "id": "3A33FCEB9B74CC15!184",
    --         "path": "/drive/root:"
    --       },
    --       "size": 0,
    --       "webUrl": "https://1drv.ms/f/s!ABXMdJvr_DM6gTo",
    --       "fileSystemInfo": {
    --         "createdDateTime": "2013-06-12T19:49:08.183Z",
    --         "lastModifiedDateTime": "2013-06-12T19:49:08.183Z"
    --       },
    --       "folder": {
    --         "childCount": 0
    --       },
    --       "shared": {
    --         "owner": {
    --           "user": {
    --             "displayName": "Matt Smith",
    --             "id": "3a33fceb9b74cc15"
    --           }
    --         },
    --         "scope": "anonymous"
    --       },
    --       "specialFolder": {
    --         "name": "public"
    --       }
    --     },
    --     {
    --       "@microsoft.graph.downloadUrl": "https://public.dm2301.livefilestore.com/y4m8Y4r_Ewfy3hIxqpU-_dxvY455X2gAZd3LJXE908zgA1ErQUm5wZpiyz6Rs0YfFb_c5SKgOFZV6HU1YpEmd0MvWbQ-dJVy2lLfRqTUnHEY8znUIQrljmTk1GR2auv4rTitRzWEZztQV0iId2-_FdQj2aZK5sdpmkdbgNuishP0NalJBsLdiBeKBVsy7A_zFTUXbw28ZzJctfyqITNUtBPxmDRzF39UWRjTo74CksCHc4",
    --       "createdBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "createdDateTime": "2017-06-02T19:08:34.14Z",
    --       "cTag": "aYzozQTMzRkNFQjlCNzRDQzE1ITQ4NjAuMjU3",
    --       "eTag": "aM0EzM0ZDRUI5Qjc0Q0MxNSE0ODYwLjA",
    --       "id": "3A33FCEB9B74CC15!4860",
    --       "lastModifiedBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "lastModifiedDateTime": "2017-06-02T19:08:34.14Z",
    --       "name": "hamlet.xml",
    --       "parentReference": {
    --         "driveId": "3a33fceb9b74cc15",
    --         "id": "3A33FCEB9B74CC15!184",
    --         "path": "/drive/root:"
    --       },
    --       "size": 279658,
    --       "webUrl": "https://1drv.ms/u/s!ABXMdJvr_DM6pXw",
    --       "file": {
    --         "hashes": {
    --           "sha1Hash": "C6AD0095E07141C97A3C6B85778602AD883F5500"
    --         },
    --         "mimeType": "application/xml"
    --       },
    --       "fileSystemInfo": {
    --         "createdDateTime": "2017-06-02T19:08:30Z",
    --         "lastModifiedDateTime": "2016-03-03T23:10:30Z"
    --       }
    --     },
    --     {
    --       "@microsoft.graph.downloadUrl": "https://public.dm2301.livefilestore.com/y4mZ4m1N8Vzd40ZtPERT8qEo4nOxt786w5uHDuX4VkessshXBY9z9wyG3rb0GYAAaCYWd64tLCmFcObsobWoLZXkGwgAdBE5ebvHTxmS3W6Z7U0ZzBHviaIa2RufoGhOtAWCImPxRKxID3wPvqPW5jCG31tCXhtrJMuGHnW2TkWg3FxJEvezSkI2PBTGpMzvGVjjX-qsHSnP5OMFyx0ikwVMaGU7_KvGcDUZtj9clz8rXQ",
    --       "createdBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "createdDateTime": "2017-06-02T19:08:53.167Z",
    --       "cTag": "aYzozQTMzRkNFQjlCNzRDQzE1ITQ4NjEuMjU3",
    --       "eTag": "aM0EzM0ZDRUI5Qjc0Q0MxNSE0ODYxLjA",
    --       "id": "3A33FCEB9B74CC15!4861",
    --       "lastModifiedBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "lastModifiedDateTime": "2017-06-02T19:08:53.167Z",
    --       "name": "msg_123_abc.wav",
    --       "parentReference": {
    --         "driveId": "3a33fceb9b74cc15",
    --         "id": "3A33FCEB9B74CC15!184",
    --         "path": "/drive/root:"
    --       },
    --       "size": 155564,
    --       "webUrl": "https://1drv.ms/u/s!ABXMdJvr_DM6pX0",
    --       "audio": {
    --         "bitrate": 128,
    --         "duration": 9720,
    --         "hasDrm": false
    --       },
    --       "file": {
    --         "hashes": {
    --           "sha1Hash": "1F51ADBDAADEAABC2D588C2A795AE86758525984"
    --         },
    --         "mimeType": "audio/wav"
    --       },
    --       "fileSystemInfo": {
    --         "createdDateTime": "2017-06-02T19:08:49Z",
    --         "lastModifiedDateTime": "2017-04-18T14:27:12Z"
    --       }
    --     },
    --     {
    --       "@microsoft.graph.downloadUrl": "https://public.dm2301.livefilestore.com/y4m5U-QanvmGcb5NeRyPaf2dy32EyX2yf_uNvPgnioU2JGrvB25yZq4uKEiQGMex99sWQ2LXcjAQbQx41C-SpqRrccIKsTvnIbbyaB45gaBSLsTeryE75p70-l4FOXb8HJWfPZmMl30BhCqpMge2ZLVo8h3uUlL7WIijap5wHdVlb0g_nm47EMDFh3USIL43kY5u4NPpoaxNEoMGYtYZ2ojzDwu-kBgKgD0S3wxCvmlD8o",
    --       "createdBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "createdDateTime": "2017-06-02T19:07:06.813Z",
    --       "cTag": "aYzozQTMzRkNFQjlCNzRDQzE1ITQ4NTkuMjU3",
    --       "eTag": "aM0EzM0ZDRUI5Qjc0Q0MxNSE0ODU5LjI",
    --       "id": "3A33FCEB9B74CC15!4859",
    --       "lastModifiedBy": {
    --         "device": {
    --           "id": "187ffebfaf8fa5"
    --         },
    --         "user": {
    --           "displayName": "Matt Smith",
    --           "id": "3a33fceb9b74cc15"
    --         },
    --         "oneDriveSync": {
    --           "@odata.type": "#microsoft.graph.identity",
    --           "id": "388149ab-8073-45aa-a68c-aac791ec9c1d"
    --         }
    --       },
    --       "lastModifiedDateTime": "2017-06-02T19:07:09.203Z",
    --       "name": "penguins.jpg",
    --       "parentReference": {
    --         "driveId": "3a33fceb9b74cc15",
    --         "id": "3A33FCEB9B74CC15!184",
    --         "path": "/drive/root:"
    --       },
    --       "size": 777835,
    --       "webUrl": "https://1drv.ms/i/s!ABXMdJvr_DM6pXs",
    --       "file": {
    --         "hashes": {
    --           "sha1Hash": "DF7BE9DC4F467187783ACA68C7CE98E4DF2172D0"
    --         },
    --         "mimeType": "image/jpeg"
    --       },
    --       "fileSystemInfo": {
    --         "createdDateTime": "2017-06-02T19:06:54Z",
    --         "lastModifiedDateTime": "2009-07-14T05:32:31Z"
    --       },
    --       "image": {
    --         "height": 768,
    --         "width": 1024
    --       },
    --       "photo": {
    --         "takenDateTime": "2008-02-18T05:07:31Z"
    --       }
    --     }
    --   ]
    -- }

    EXEC @hr = sp_OADestroy @json
    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @lastMod
    EXEC @hr = sp_OADestroy @photoTaken


END
GO