0

Good Morning

I would like to download multiple files from Share Point online library using REST API and VB script.

Do we have any examples or documentation how to use it?

Thanks for any help Adam

1
1

You could try the following code:

Dim success As Boolean
Dim http As New Chilkat.Http

'  Change these things...
'  Make sure to use "https" and end in a "/".
Dim siteUrl As String = "https://mydomain.sharepoint.com/"
'  The username is an email address.
Dim username As String = "username@mydomain.com"

'  The jsonExtra is for future use, if extra information is required for particular integrations.
Dim jsonExtra As New Chilkat.JsonObject

Dim ssPassword As New Chilkat.SecureString
ssPassword.Append("mypassword")

'  Set properties to save/send cookies, and specify a cookie directory.
'  If the CookieDir = "memory", then the SPOIDCRL cookie is persisted in memory for this HTTP object instance only.
'  To persist the SharePoint authentication cookie for other HTTP objects, and for future application runs,
'  set the CookieDir equal to a directory path (not a specific file path, but a directory path where cookie files
'  are to be created).
http.SaveCookies = True
http.SendCookies = True
http.CookieDir = "memory"

'  The SharePointOnlineAuth method is introduced in Chilkat v9.5.0.73
success = http.SharePointOnlineAuth(siteUrl,username,ssPassword,jsonExtra)
If (success = False) Then
    Debug.WriteLine(http.LastErrorText)
    Exit Sub
End If



Debug.WriteLine("Success! We have the SPOIDCRL cookie...")


'  SharePoint authenticated requests may now be sent because the authentication cookie is automatically included.
'  For example:
Dim sbResponseXml As New Chilkat.StringBuilder
success = http.QuickGetSb("https://mydomain.sharepoint.com/_api/web/GetFolderByServerRelativeUrl('/Documents')/Files",sbResponseXml)
If (success = False) Then
    Debug.WriteLine(http.LastErrorText)
    Exit Sub
End If


Debug.WriteLine("Response status code = " & http.LastStatus)

Dim xml As New Chilkat.Xml
xml.LoadSb(sbResponseXml,True)
Debug.WriteLine(xml.GetXml())

Source:https://www.example-code.com/vbnet/sharepoint_online_authentication.asp

1
  • Thank You for this! – Odyn Oct 7 '20 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.