Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

VBScript Examples

Web API Categories

ASN.1
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
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
NTLM
OAuth1
OAuth2
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
PDF Signatures
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(VBScript) Retrieve the metadata for a DriveItem

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 ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)

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

set http = 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.)
http.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
http.FollowRedirects = 1

' This example will get the metadata for /Misc/wildlife/penguins.jpg
success = http.SetUrlVar("item_path","Misc/wildlife/penguins.jpg")

metaData = http.QuickGetStr("https://graph.microsoft.com/v1.0/me/drive/root:/{$item_path}")
If (http.LastMethodSuccess <> 1) Then
    outFile.WriteLine(http.LastErrorText)
    WScript.Quit
End If

set json = CreateObject("Chilkat_9_5_0.JsonObject")
json.EmitCompact = 0
success = json.Load(metaData)
outFile.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
    outFile.WriteLine("Response Status Code = " & http.LastStatus)
    outFile.WriteLine("Failed.")
    WScript.Quit
End If

' Demonstrate how to parse the JSON...

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

outFile.Close

 

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