Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

VB.NET Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(VB.NET) Retrieve the metadata for a DriveItem

See more OneDrive Examples

Fetches 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

Chilkat .NET Downloads

Chilkat .NET Framework

Chilkat for .NET Core

' 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
Dim json As New Chilkat.JsonObject
json.UpdateString("client_id","2871da2c-8176-4b7f-869b-2311aa82e743")
json.UpdateString("client_secret","2hu9Q~r5QuryUcEkNbg1btLtnfU1VUXzhSCG6brH")
json.UpdateString("scope","https://graph.microsoft.com/.default")
json.UpdateString("token_endpoint","https://login.microsoftonline.com/114d7ed6-71bf-4dbe-a866-748364121bf2/oauth2/v2.0/token")

Dim http As New Chilkat.Http
http.AuthToken = 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
http.FollowRedirects = True

' This example will get the metadata for /Misc/wildlife/penguins.jpg
http.SetUrlVar("item_path","Misc//penguins.jpg")
http.SetUrlVar("user_id","4fe732c3-322e-4a6b-b729-2fd1eb5c6104")

Dim metaData As String = http.QuickGetStr("https://graph.microsoft.com/v1.0/users/{$user_id}/drive/root:/{$item_path}")
If (http.LastMethodSuccess <> True) Then
    Debug.WriteLine(http.LastErrorText)
    Exit Sub
End If



json.EmitCompact = False
Dim success As Boolean = json.Load(metaData)
Debug.WriteLine(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 (http.LastStatus <> 200) Then
    Debug.WriteLine("Response Status Code = " & http.LastStatus)
    Debug.WriteLine("Failed.")
    Exit Sub
End If


' Demonstrate how to parse the JSON...




Dim odata_context As String = json.StringOf("""@odata.context""")
Dim microsoft_graph_downloadUrl As String = json.StringOf("""@microsoft.graph.downloadUrl""")
Dim createdDateTime As String = json.StringOf("createdDateTime")
Dim cTag As String = json.StringOf("cTag")
Dim eTag As String = json.StringOf("eTag")
Dim id As String = json.StringOf("id")
Dim lastModifiedDateTime As String = json.StringOf("lastModifiedDateTime")
Dim name As String = json.StringOf("name")
Dim size As Integer = json.IntOf("size")
Dim webUrl As String = json.StringOf("webUrl")
Dim ratingRating As Integer = json.IntOf("rating.rating")
Dim ratingSimpleRating As Integer = json.IntOf("rating.simpleRating")
Dim createdByUserDisplayName As String = json.StringOf("createdBy.user.displayName")
Dim createdByUserId As String = json.StringOf("createdBy.user.id")
Dim lastModifiedByUserDisplayName As String = json.StringOf("lastModifiedBy.user.displayName")
Dim lastModifiedByUserId As String = json.StringOf("lastModifiedBy.user.id")
Dim parentReferenceDriveId As String = json.StringOf("parentReference.driveId")
Dim parentReferenceDriveType As String = json.StringOf("parentReference.driveType")
Dim parentReferenceId As String = json.StringOf("parentReference.id")
Dim parentReferenceName As String = json.StringOf("parentReference.name")
Dim parentReferencePath As String = json.StringOf("parentReference.path")
Dim fileMimeType As String = json.StringOf("file.mimeType")
Dim fileHashesSha1Hash As String = json.StringOf("file.hashes.sha1Hash")
Dim fileSystemInfoCreatedDateTime As String = json.StringOf("fileSystemInfo.createdDateTime")
Dim fileSystemInfoLastModifiedDateTime As String = json.StringOf("fileSystemInfo.lastModifiedDateTime")
Dim imageHeight As Integer = json.IntOf("image.height")
Dim imageWidth As Integer = json.IntOf("image.width")
Dim photoTakenDateTime As String = json.StringOf("photo.takenDateTime")
Dim sharedScope As String = json.StringOf("shared.scope")
Dim sharedOwnerUserDisplayName As String = json.StringOf("shared.owner.user.displayName")
Dim sharedOwnerUserId As String = json.StringOf("shared.owner.user.id")

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.