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
(PowerBuilder) 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
integer li_rc oleobject loo_Json oleobject loo_Http string ls_MetaData integer li_Success string ls_Odata_context string ls_Microsoft_graph_downloadUrl string ls_CreatedDateTime string ls_CTag string ls_ETag string ls_Id string ls_LastModifiedDateTime string ls_Name integer li_Size string ls_WebUrl integer li_RatingRating integer li_RatingSimpleRating string ls_CreatedByUserDisplayName string ls_CreatedByUserId string ls_LastModifiedByUserDisplayName string ls_LastModifiedByUserId string ls_ParentReferenceDriveId string ls_ParentReferenceDriveType string ls_ParentReferenceId string ls_ParentReferenceName string ls_ParentReferencePath string ls_FileMimeType string ls_FileHashesSha1Hash string ls_FileSystemInfoCreatedDateTime string ls_FileSystemInfoLastModifiedDateTime integer li_ImageHeight integer li_ImageWidth string ls_PhotoTakenDateTime string ls_SharedScope string ls_SharedOwnerUserDisplayName string ls_SharedOwnerUserId // 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 loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") if li_rc < 0 then destroy loo_Json MessageBox("Error","Connecting to COM object failed") return end if loo_Json.UpdateString("client_id","2871da2c-8176-4b7f-869b-2311aa82e743") loo_Json.UpdateString("client_secret","2hu9Q~~r5QuryUcEkNbg1btLtnfU1VUXzhSCG6brH") loo_Json.UpdateString("scope","https://graph.microsoft.com/.default") loo_Json.UpdateString("token_endpoint","https://login.microsoftonline.com/114d7ed6-71bf-4dbe-a866-748364121bf2/oauth2/v2.0/token") loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") loo_Http.AuthToken = loo_Json.Emit() // 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 loo_Http.FollowRedirects = 1 // This example will get the metadata for /Misc/wildlife/penguins.jpg loo_Http.SetUrlVar("item_path","Misc//penguins.jpg") loo_Http.SetUrlVar("user_id","4fe732c3-322e-4a6b-b729-2fd1eb5c6104") ls_MetaData = loo_Http.QuickGetStr("https://graph.microsoft.com/v1.0/users/{$user_id}/drive/root:/{$item_path}") if loo_Http.LastMethodSuccess <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_Json destroy loo_Http return end if loo_Json.EmitCompact = 0 li_Success = loo_Json.Load(ls_MetaData) Write-Debug loo_Json.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 loo_Http.LastStatus <> 200 then Write-Debug "Response Status Code = " + string(loo_Http.LastStatus) Write-Debug "Failed." destroy loo_Json destroy loo_Http return end if // Demonstrate how to parse the JSON... ls_Odata_context = loo_Json.StringOf("~"@odata.context~"") ls_Microsoft_graph_downloadUrl = loo_Json.StringOf("~"@microsoft.graph.downloadUrl~"") ls_CreatedDateTime = loo_Json.StringOf("createdDateTime") ls_CTag = loo_Json.StringOf("cTag") ls_ETag = loo_Json.StringOf("eTag") ls_Id = loo_Json.StringOf("id") ls_LastModifiedDateTime = loo_Json.StringOf("lastModifiedDateTime") ls_Name = loo_Json.StringOf("name") li_Size = loo_Json.IntOf("size") ls_WebUrl = loo_Json.StringOf("webUrl") li_RatingRating = loo_Json.IntOf("rating.rating") li_RatingSimpleRating = loo_Json.IntOf("rating.simpleRating") ls_CreatedByUserDisplayName = loo_Json.StringOf("createdBy.user.displayName") ls_CreatedByUserId = loo_Json.StringOf("createdBy.user.id") ls_LastModifiedByUserDisplayName = loo_Json.StringOf("lastModifiedBy.user.displayName") ls_LastModifiedByUserId = loo_Json.StringOf("lastModifiedBy.user.id") ls_ParentReferenceDriveId = loo_Json.StringOf("parentReference.driveId") ls_ParentReferenceDriveType = loo_Json.StringOf("parentReference.driveType") ls_ParentReferenceId = loo_Json.StringOf("parentReference.id") ls_ParentReferenceName = loo_Json.StringOf("parentReference.name") ls_ParentReferencePath = loo_Json.StringOf("parentReference.path") ls_FileMimeType = loo_Json.StringOf("file.mimeType") ls_FileHashesSha1Hash = loo_Json.StringOf("file.hashes.sha1Hash") ls_FileSystemInfoCreatedDateTime = loo_Json.StringOf("fileSystemInfo.createdDateTime") ls_FileSystemInfoLastModifiedDateTime = loo_Json.StringOf("fileSystemInfo.lastModifiedDateTime") li_ImageHeight = loo_Json.IntOf("image.height") li_ImageWidth = loo_Json.IntOf("image.width") ls_PhotoTakenDateTime = loo_Json.StringOf("photo.takenDateTime") ls_SharedScope = loo_Json.StringOf("shared.scope") ls_SharedOwnerUserDisplayName = loo_Json.StringOf("shared.owner.user.displayName") ls_SharedOwnerUserId = loo_Json.StringOf("shared.owner.user.id") destroy loo_Json destroy loo_Http |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.