Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) Retrieve the metadata for a DriveItemFetches the JSON metadata for a DriveItem. For more information, see https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get?view=odsp-graph-online
LOCAL loHttp LOCAL lcMetaData LOCAL loJson LOCAL lnSuccess LOCAL lcOdata_context LOCAL lcMicrosoft_graph_downloadUrl LOCAL lcCreatedDateTime LOCAL lcCTag LOCAL lcETag LOCAL lcId LOCAL lcLastModifiedDateTime LOCAL lcName LOCAL lnSize LOCAL lcWebUrl LOCAL lnRatingRating LOCAL lnRatingSimpleRating LOCAL lcCreatedByUserDisplayName LOCAL lcCreatedByUserId LOCAL lcLastModifiedByUserDisplayName LOCAL lcLastModifiedByUserId LOCAL lcParentReferenceDriveId LOCAL lcParentReferenceDriveType LOCAL lcParentReferenceId LOCAL lcParentReferenceName LOCAL lcParentReferencePath LOCAL lcFileMimeType LOCAL lcFileHashesSha1Hash LOCAL lcFileSystemInfoCreatedDateTime LOCAL lcFileSystemInfoLastModifiedDateTime LOCAL lnImageHeight LOCAL lnImageWidth LOCAL lcPhotoTakenDateTime LOCAL lcSharedScope LOCAL lcSharedOwnerUserDisplayName LOCAL lcSharedOwnerUserId * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. loHttp = CreateObject('Chilkat_9_5_0.Http') * Use your previously obtained access token here: * See the following examples for getting an access token: * Get Microsoft Graph OAuth2 Access Token (Azure AD v2.0 Endpoint). * Get Microsoft Graph OAuth2 Access Token (Azure AD Endpoint). * Refresh Access Token (Azure AD v2.0 Endpoint). * Refresh Access Token (Azure AD Endpoint). * (Make sure your token was obtained with the FilesRead or Files.ReadWrite scope.) loHttp.AuthToken = "MICROSOFT_GRAPH_ACCESS_TOKEN" * Sends the following GET request: * GET https://graph.microsoft.com/v1.0/me/drive/root:/{item-path} * Make sure to automatically follow redirects loHttp.FollowRedirects = 1 * This example will get the metadata for /Misc/wildlife/penguins.jpg loHttp.SetUrlVar("item_path","Misc/wildlife/penguins.jpg") lcMetaData = loHttp.QuickGetStr("https://graph.microsoft.com/v1.0/me/drive/root:/{$item_path}") IF (loHttp.LastMethodSuccess <> 1) THEN ? loHttp.LastErrorText RELEASE loHttp CANCEL ENDIF loJson = CreateObject('Chilkat_9_5_0.JsonObject') loJson.EmitCompact = 0 lnSuccess = loJson.Load(lcMetaData) ? loJson.Emit() * Sample JSON metadata result: * { * "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('admin%40chilkat.io')/drive/root/$entity", * "@microsoft.graph.downloadUrl": "https://public.dm.files.1drv.com/y4mh0z_Og97O7Q...o2q1HhNBU", * "createdDateTime": "2017-06-04T20:40:22.48Z", * "cTag": "aYzozQTMzRkNFQjlCNzRDQzE1ITQ4NzIuMjU3", * "eTag": "aM0EzM0ZDRUI5Qjc0Q0MxNSE0ODcyLjY", * "id": "3A33FCEB9B74CC15!4872", * "lastModifiedDateTime": "2018-10-20T18:22:29.977Z", * "name": "penguins.jpg", * "size": 777835, * "webUrl": "https://1drv.ms/i/s!ABXMdJvr_DM6pgg", * "rating": { * "rating": 75, * "simpleRating": 4 * }, * "createdBy": { * "user": { * "displayName": "Joe Programmer", * "id": "3a33fceb9b74cc15" * } * }, * "lastModifiedBy": { * "user": { * "displayName": "Joe Programmer", * "id": "3a33fceb9b74cc15" * } * }, * "parentReference": { * "driveId": "3a33fceb9b74cc15", * "driveType": "personal", * "id": "3A33FCEB9B74CC15!4871", * "name": "wildlife", * "path": "/drive/root:/Misc/wildlife" * }, * "file": { * "mimeType": "image/jpeg", * "hashes": { * "sha1Hash": "DF7BE9DC4F467187783ACA68C7CE98E4DF2172D0" * } * }, * "fileSystemInfo": { * "createdDateTime": "2017-06-04T20:40:22.48Z", * "lastModifiedDateTime": "2009-07-14T05:32:31.674Z" * }, * "image": { * "height": 768, * "width": 1024 * }, * "photo": { * "takenDateTime": "2008-02-18T05:07:31Z" * }, * "shared": { * "scope": "users", * "owner": { * "user": { * "displayName": "Joe Programmer", * "id": "3a33fceb9b74cc15" * } * } * } * } * * If the response status code was not 200, then it failed. IF (loHttp.LastStatus <> 200) THEN ? "Response Status Code = " + STR(loHttp.LastStatus) ? "Failed." RELEASE loHttp RELEASE loJson CANCEL ENDIF * Demonstrate how to parse the JSON... lcOdata_context = loJson.StringOf('"@odata.context"') lcMicrosoft_graph_downloadUrl = loJson.StringOf('"@microsoft.graph.downloadUrl"') lcCreatedDateTime = loJson.StringOf("createdDateTime") lcCTag = loJson.StringOf("cTag") lcETag = loJson.StringOf("eTag") lcId = loJson.StringOf("id") lcLastModifiedDateTime = loJson.StringOf("lastModifiedDateTime") lcName = loJson.StringOf("name") lnSize = loJson.IntOf("size") lcWebUrl = loJson.StringOf("webUrl") lnRatingRating = loJson.IntOf("rating.rating") lnRatingSimpleRating = loJson.IntOf("rating.simpleRating") lcCreatedByUserDisplayName = loJson.StringOf("createdBy.user.displayName") lcCreatedByUserId = loJson.StringOf("createdBy.user.id") lcLastModifiedByUserDisplayName = loJson.StringOf("lastModifiedBy.user.displayName") lcLastModifiedByUserId = loJson.StringOf("lastModifiedBy.user.id") lcParentReferenceDriveId = loJson.StringOf("parentReference.driveId") lcParentReferenceDriveType = loJson.StringOf("parentReference.driveType") lcParentReferenceId = loJson.StringOf("parentReference.id") lcParentReferenceName = loJson.StringOf("parentReference.name") lcParentReferencePath = loJson.StringOf("parentReference.path") lcFileMimeType = loJson.StringOf("file.mimeType") lcFileHashesSha1Hash = loJson.StringOf("file.hashes.sha1Hash") lcFileSystemInfoCreatedDateTime = loJson.StringOf("fileSystemInfo.createdDateTime") lcFileSystemInfoLastModifiedDateTime = loJson.StringOf("fileSystemInfo.lastModifiedDateTime") lnImageHeight = loJson.IntOf("image.height") lnImageWidth = loJson.IntOf("image.width") lcPhotoTakenDateTime = loJson.StringOf("photo.takenDateTime") lcSharedScope = loJson.StringOf("shared.scope") lcSharedOwnerUserDisplayName = loJson.StringOf("shared.owner.user.displayName") lcSharedOwnerUserId = loJson.StringOf("shared.owner.user.id") RELEASE loHttp RELEASE loJson |
© 2000-2023 Chilkat Software, Inc. All Rights Reserved.