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) SharePoint -- Get Files in Root FolderSee more SharePoint ExamplesGets the list of files that exist in the root folder.
integer li_rc oleobject loo_Http oleobject loo_SbJson integer li_Success oleobject loo_Json integer li_NumFiles oleobject loo_LastMod oleobject loo_Dt integer li_BLocal integer i string ls_Filename string ls_FileRelativeUri integer li_FileSize string ls_SLastModified // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // ------------------------------------------------------------------------- // The following comments apply to SharePoint Windows classic authentication. // ------------------------------------------------------------------------- // For example, imagine our SharePoint endpoint is https://xyzoffice.mycompany.com/ // The SHAREPOINT_NTLM_DOMAIN would be "mycompany.com" // The SHAREPOINT_HTTPS_DOMAIN would be "xyzoffice.mycompany.com" // Also, the SHAREPOINT_USERNAME would be just the name, not a full email address. // for example, "chilkat" instead of "chilkat@mycompany.com" loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // If SharePoint Windows classic authentication is used, then set the // Login, Password, LoginDomain, and NtlmAuth properties. loo_Http.Login = "SHAREPOINT_USERNAME" loo_Http.Password = "SHAREPOINT_PASSWORD" loo_Http.LoginDomain = "SHAREPOINT_NTLM_DOMAIN" loo_Http.NtlmAuth = 1 // ------------------------------------------------------------------------- // 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 loo_Http.Accept = "application/json;odata=verbose" loo_Http.AcceptCharset = "utf-8" // If your Sharepoint site is within a site collection, then use "https://SHAREPOINT_HTTPS_DOMAIN/sites/teamA/_api/web/GetFolderByServerRelativeUrl('/sites/teamA/')/Files" where "teamA" is the name of the site. loo_SbJson = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbJson.ConnectToNewObject("Chilkat.StringBuilder") li_Success = loo_Http.QuickGetSb("https://SHAREPOINT_HTTPS_DOMAIN/_api/web/GetFolderByServerRelativeUrl('/')/Files",loo_SbJson) if li_Success <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_SbJson return end if loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.LoadSb(loo_SbJson) // Iterate over the results and get each file's name, size, and last-modified date/time. li_NumFiles = loo_Json.SizeOfArray("d.results") Write-Debug "Number of Files in the SharePoint root folder = " + string(li_NumFiles) loo_LastMod = create oleobject // Use "Chilkat_9_5_0.CkDateTime" for versions of Chilkat < 10.0.0 li_rc = loo_LastMod.ConnectToNewObject("Chilkat.CkDateTime") li_BLocal = 1 i = 0 do while i < li_NumFiles loo_Json.I = i ls_Filename = loo_Json.StringOf("d.results[i].Name") ls_FileRelativeUri = loo_Json.StringOf("d.results[i].ServerRelativeUrl") li_FileSize = loo_Json.IntOf("d.results[i].Length") ls_SLastModified = loo_Json.StringOf("d.results[i].TimeLastModified") Write-Debug string(i + 1) + ": " + ls_Filename Write-Debug " Relative URI: " + ls_FileRelativeUri Write-Debug " Size in Bytes: " + string(li_FileSize) // Show the last-modified date/time in the local timezone. loo_LastMod.SetFromTimestamp(ls_SLastModified) loo_Dt = loo_LastMod.GetDtObj(li_BLocal) Write-Debug " Last-Modified: " + string(loo_Dt.Day) + "/" + string(loo_Dt.Month) + "/" + string(loo_Dt.Year) + " " + string(loo_Dt.Hour) + ":" + string(loo_Dt.Minute) destroy loo_Dt i = i + 1 loop // The output of this program when I tested it: // Number of Files in the SharePoint root folder = 5 // 1: Documentstester1.txt // Relative URI: /Documentstester1.txt // Size in Bytes: 17 // Last-Modified: 6/4/2017 11:31 // 2: Documents11_D42_Device_70_IP.xlsx // Relative URI: /Documents11_D42_Device_70_IP.xlsx // Size in Bytes: 17472 // Last-Modified: 6/4/2017 10:54 // 3: default.aspx // Relative URI: /default.aspx // Size in Bytes: 3960 // Last-Modified: 26/10/2015 20:47 // 4: DocumentsVCAC NEW Admin and RA bacgrounds.pptx // Relative URI: /DocumentsVCAC NEW Admin and RA bacgrounds.pptx // Size in Bytes: 11867024 // Last-Modified: 6/4/2017 10:51 // 5: DocumentsVCAC_Installer_Web_Sites_Installation.docx // Relative URI: /DocumentsVCAC_Installer_Web_Sites_Installation.docx // Size in Bytes: 529482 // Last-Modified: 6/4/2017 11:0 destroy loo_Http destroy loo_SbJson destroy loo_Json destroy loo_LastMod |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.