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
(DataFlex) Retrieve the metadata for a DriveItemSee more OneDrive ExamplesFetches 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
Use ChilkatAx-win32.pkg Procedure Test Handle hoJson Boolean iSuccess Handle hoHttp String sMetaData Boolean iSuccess String sOdata_context String sMicrosoft_graph_downloadUrl String sCreatedDateTime String sCTag String sETag String sId String sLastModifiedDateTime String sName Integer iSize String sWebUrl Integer iRatingRating Integer iRatingSimpleRating String sCreatedByUserDisplayName String sCreatedByUserId String sLastModifiedByUserDisplayName String sLastModifiedByUserId String sParentReferenceDriveId String sParentReferenceDriveType String sParentReferenceId String sParentReferenceName String sParentReferencePath String sFileMimeType String sFileHashesSha1Hash String sFileSystemInfoCreatedDateTime String sFileSystemInfoLastModifiedDateTime Integer iImageHeight Integer iImageWidth String sPhotoTakenDateTime String sSharedScope String sSharedOwnerUserDisplayName String sSharedOwnerUserId String sTemp1 Integer iTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // Use your client ID, client secret, and tenant ID in the following lines Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComUpdateString Of hoJson "client_id" "2871da2c-8176-4b7f-869b-2311aa82e743" To iSuccess Get ComUpdateString Of hoJson "client_secret" "2hu9Q~r5QuryUcEkNbg1btLtnfU1VUXzhSCG6brH" To iSuccess Get ComUpdateString Of hoJson "scope" "https://graph.microsoft.com/.default" To iSuccess Get ComUpdateString Of hoJson "token_endpoint" "https://login.microsoftonline.com/114d7ed6-71bf-4dbe-a866-748364121bf2/oauth2/v2.0/token" To iSuccess Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Get ComEmit Of hoJson To sTemp1 Set ComAuthToken Of hoHttp To sTemp1 // Sends the following GET request: // GET https://graph.microsoft.com/v1.0/users/{user-id}/drive/root:/{item-path} // Make sure to automatically follow redirects Set ComFollowRedirects Of hoHttp To True // This example will get the metadata for /Misc/wildlife/penguins.jpg Get ComSetUrlVar Of hoHttp "item_path" "Misc//penguins.jpg" To iSuccess Get ComSetUrlVar Of hoHttp "user_id" "4fe732c3-322e-4a6b-b729-2fd1eb5c6104" To iSuccess Get ComQuickGetStr Of hoHttp "https://graph.microsoft.com/v1.0/users/{$user_id}/drive/root:/{$item_path}" To sMetaData Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Set ComEmitCompact Of hoJson To False Get ComLoad Of hoJson sMetaData To iSuccess Get ComEmit Of hoJson To sTemp1 Showln sTemp1 // 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. Get ComLastStatus Of hoHttp To iTemp1 If (iTemp1 <> 200) Begin Get ComLastStatus Of hoHttp To iTemp1 Showln "Response Status Code = " iTemp1 Showln "Failed." Procedure_Return End // Demonstrate how to parse the JSON... Get ComStringOf Of hoJson '"@odata.context"' To sOdata_context Get ComStringOf Of hoJson '"@microsoft.graph.downloadUrl"' To sMicrosoft_graph_downloadUrl Get ComStringOf Of hoJson "createdDateTime" To sCreatedDateTime Get ComStringOf Of hoJson "cTag" To sCTag Get ComStringOf Of hoJson "eTag" To sETag Get ComStringOf Of hoJson "id" To sId Get ComStringOf Of hoJson "lastModifiedDateTime" To sLastModifiedDateTime Get ComStringOf Of hoJson "name" To sName Get ComIntOf Of hoJson "size" To iSize Get ComStringOf Of hoJson "webUrl" To sWebUrl Get ComIntOf Of hoJson "rating.rating" To iRatingRating Get ComIntOf Of hoJson "rating.simpleRating" To iRatingSimpleRating Get ComStringOf Of hoJson "createdBy.user.displayName" To sCreatedByUserDisplayName Get ComStringOf Of hoJson "createdBy.user.id" To sCreatedByUserId Get ComStringOf Of hoJson "lastModifiedBy.user.displayName" To sLastModifiedByUserDisplayName Get ComStringOf Of hoJson "lastModifiedBy.user.id" To sLastModifiedByUserId Get ComStringOf Of hoJson "parentReference.driveId" To sParentReferenceDriveId Get ComStringOf Of hoJson "parentReference.driveType" To sParentReferenceDriveType Get ComStringOf Of hoJson "parentReference.id" To sParentReferenceId Get ComStringOf Of hoJson "parentReference.name" To sParentReferenceName Get ComStringOf Of hoJson "parentReference.path" To sParentReferencePath Get ComStringOf Of hoJson "file.mimeType" To sFileMimeType Get ComStringOf Of hoJson "file.hashes.sha1Hash" To sFileHashesSha1Hash Get ComStringOf Of hoJson "fileSystemInfo.createdDateTime" To sFileSystemInfoCreatedDateTime Get ComStringOf Of hoJson "fileSystemInfo.lastModifiedDateTime" To sFileSystemInfoLastModifiedDateTime Get ComIntOf Of hoJson "image.height" To iImageHeight Get ComIntOf Of hoJson "image.width" To iImageWidth Get ComStringOf Of hoJson "photo.takenDateTime" To sPhotoTakenDateTime Get ComStringOf Of hoJson "shared.scope" To sSharedScope Get ComStringOf Of hoJson "shared.owner.user.displayName" To sSharedOwnerUserDisplayName Get ComStringOf Of hoJson "shared.owner.user.id" To sSharedOwnerUserId End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.