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

DataFlex 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

 

 

 

(DataFlex) SharePoint -- Get File Property

See more SharePoint Examples

Demonstrates how to get a specific property of a SharePoint file. Any of the following properties can be retrieved:

  • Author: Gets a value that specifies the user who added the file.
  • CheckedOutByUser: Gets a value that returns the user who has checked out the file.
  • CheckInComment: Gets a value that returns the comment used when a document is checked in to a document library.
  • CheckOutType: Gets a value that indicates how the file is checked out of a document library. Represents an
  • ContentTag: Returns internal version of content, used to validate document equality for read purposes.
  • CustomizedPageStatus: Gets a value that specifies the customization status of the file. Represents an
  • ETag: Gets a value that specifies the ETag value.
  • Exists: Gets a value that specifies whether the file exists.
  • Length: Gets the size of the file in bytes, excluding the size of any Web Parts that are used in the file.
  • Level: Gets a value that specifies the publishing level of the file. Represents an
  • ListItemAllFields: Gets a value that specifies the list item field values for the list item corresponding to the file.
  • LockedByUser: Gets a value that returns the user that owns the current lock on the file.
  • MajorVersion: Gets a value that specifies the major version of the file.
  • MinorVersion: Gets a value that specifies the minor version of the file.
  • ModifiedBy: Gets a value that returns the user who last modified the file.
  • Name: Gets the name of the file including the extension.
  • ServerRelativeUrl: Gets the relative URL of the file based on the URL for the server.
  • TimeCreated: Gets a value that specifies when the file was created.
  • TimeLastModified: Gets a value that specifies when the file was last modified.
  • Title: Gets a value that specifies the display name of the file.
  • UiVersion: Gets a value that specifies the implementation-specific version identifier of the file.
  • UiVersionLabel: Gets a value that specifies the implementation-specific version identifier of the file.
  • Versions: Gets a value that returns a collection of file version objects that represent the versions of the file.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    String sUrl
    String sJsonReply
    Handle hoJson
    Boolean iSuccess
    Integer iNumVersions
    Integer i
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // If SharePoint Windows classic authentication is used, then set the 
    // Login, Password, LoginDomain, and NtlmAuth properties.
    Set ComLogin Of hoHttp To "SHAREPOINT_USERNAME"
    Set ComPassword Of hoHttp To "SHAREPOINT_PASSWORD"
    Set ComLoginDomain Of hoHttp To "SHAREPOINT_NTLM_DOMAIN"
    Set ComNtlmAuth Of hoHttp To True

    // The more common case is to use SharePoint Online authentication (via the SPOIDCRL cookie).
    // If so, do not set Login, Password, LoginDomain, and NtlmAuth, and instead
    // establish the cookie as shown at SharePoint Online Authentication

    // Indicate that we want a JSON reply
    Set ComAccept Of hoHttp To "application/json;odata=verbose"
    Set ComAcceptCharset Of hoHttp To "utf-8"

    // Get the Author property.
    Move "https://SHAREPOINT_HTTPS_DOMAIN/_api/web/GetFileByServerRelativeUrl('/Documents/VCAC-document.docx')/Author" To sUrl

    Get ComQuickGetStr Of hoHttp sUrl To sJsonReply
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComLoad Of hoJson sJsonReply To iSuccess
    Set ComEmitCompact Of hoJson To False

    // Make sure it was a success response, and that we really have metadata.
    // If it was an error response, then the JSON is error information..
    Get ComLastStatus Of hoHttp To iTemp1
    If (iTemp1 <> 200) Begin
        Get ComEmit Of hoJson To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    // The Author property returns JSON looking like this:

    // {
    //   "d": {
    //     "__metadata": {
    //       "id": "Web/GetUserById(18)",
    //       "uri": "https://SHAREPOINT_HTTPS_DOMAIN/_api/Web/GetUserById(18)",
    //       "type": "SP.User"
    //     },
    //     "Groups": {
    //       "__deferred": {
    //         "uri": "https://SHAREPOINT_HTTPS_DOMAIN/_api/Web/GetUserById(18)/Groups"
    //       }
    //     },
    //     "Id": 18,
    //     "IsHiddenInUI": false,
    //     "LoginName": "i:0#.w|mydomain\\msmith",
    //     "Title": "Mike Smith",
    //     "PrincipalType": 1,
    //     "Email": "msmith@mydomain.com",
    //     "IsSiteAdmin": false,
    //     "UserId": {
    //       "__metadata": {
    //         "type": "SP.UserIdInfo"
    //       },
    //       "NameId": "s-1-5-21-3433503314-2897774614-343593928-1137",
    //       "NameIdIssuer": "urn:office:idp:activedirectory"
    //     }
    //   }
    // }
    // 

    // Get the Title and Email:
    Showln "----"
    Get ComStringOf Of hoJson "d.Title" To sTemp1
    Showln "Title: " sTemp1
    Get ComStringOf Of hoJson "d.Email" To sTemp1
    Showln "Email: " sTemp1
    Showln "----"

    // --------------------------------------------------------------------

    // Get the Versions property.
    Move "https://SHAREPOINT_HTTPS_DOMAIN/_api/web/GetFileByServerRelativeUrl('/Documents/VCAC-document.docx')/Versions" To sUrl

    Get ComQuickGetStr Of hoHttp sUrl To sJsonReply
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComLoad Of hoJson sJsonReply To iSuccess
    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    // The Versions JSON reply looks like this:

    // {
    //   "d": {
    //     "results": [
    //       {
    //         "__metadata": {
    //           "id": "a8d025e2-8255-4487-9edb-9e796ab2889c",
    //           "type": "SP.FileVersion"
    //         },
    //         "CreatedBy": {
    //           "__deferred": {
    //             "uri": "https://SHAREPOINT_HTTPS_DOMAIN/_api/CreatedBy"
    //           }
    //         },
    //         "CheckInComment": "",
    //         "Created": "2016-03-15T02:22:26Z",
    //         "ID": 1,
    //         "IsCurrentVersion": false,
    //         "Size": 21082,
    //         "Url": "_vti_history/1/Documents/VCAC-document.docx",
    //         "VersionLabel": "0.1"
    //       },
    //       {
    //         "__metadata": {
    //           "id": "8ab3eadd-9126-4f65-a2a3-3b0689c592d6",
    //           "type": "SP.FileVersion"
    //         },
    //         "CreatedBy": {
    //           "__deferred": {
    //             "uri": "https://SHAREPOINT_HTTPS_DOMAIN/_api/CreatedBy"
    //           }
    //         },
    //         "CheckInComment": "",
    //         "Created": "2016-03-15T05:28:24Z",
    //         "ID": 2,
    //         "IsCurrentVersion": false,
    //         "Size": 21082,
    //         "Url": "_vti_history/2/Documents/VCAC-document.docx",
    //         "VersionLabel": "0.2"
    //       }
    //     ]
    //   }
    // }
    // 

    // Get each VersionLabel, Size, and Url...
    Get ComSizeOfArray Of hoJson "d.results" To iNumVersions
    Move 0 To i
    While (i < iNumVersions)
        Set ComI Of hoJson To i
        Showln "---- i = " i
        Get ComStringOf Of hoJson "d.results[i].VersionLabel" To sTemp1
        Showln "VersionLabel: " sTemp1
        Get ComStringOf Of hoJson "d.results[i].Url" To sTemp1
        Showln "Url: " sTemp1
        Get ComIntOf Of hoJson "d.results[i].Size" To iTemp1
        Showln "Size: " iTemp1
        Move (i + 1) To i
    Loop

    // The output is:

    // ---- i = 0
    // VersionLabel: 0.1
    // Url: _vti_history/1/Documents/VCAC-document.docx
    // Size: 21082
    // ---- i = 1
    // VersionLabel: 0.2
    // Url: _vti_history/2/Documents/VCAC-document.docx
    // Size: 21082


End_Procedure

 

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