I managed to get this far by following this article -
HTML Code:
https://medium.com/@anoopt/accessing-sharepoint-data-using-postman-sharepoint-rest-api-76b70630bcbf
to get the Access Token to use in my VBA as below. So now I have all the data in an XML however large as I am battling to filter down the information to only return what I need which is Folder Name and a metadata field called CompanyNumber. Can anyone assist in looping through the XML to only return the Folder Name and CompanyNumber (Metadata Column) that is associated to that Folder?
Public Sub UserForm_Initialize()
Dim xmlhttp As New MSXML2.XMLHTTP60, myURL As String
Client.Clear
auth = "Bearer " & "this is unique for everyone so you will need to get your own access tokenNRS1NSWSIsImtpZCI6IkN0VHVoTUptRDVNN0RMZHpEMnYyeDNRS1NSWSJ9." _
& "this is just an example of how it will look without this text but follow the article above to get your access tokenmQ3eKViuvokdbiWyF76s11JAUCmj2bQ0q5JO1DfGh25LjeHWw"
sUrl = "https://fumble.sharepoint.com/sites/Review/_api/web/GetFolderByServerRelativeUrl('Shared%20Documents/General/NewFolder')?$expand=Folders/ListItemAllFields/FieldValuesAsText&$select=ItemCount,Folders/ItemCount,Folders/Name,Folders/ListItemAllFields/FieldValuesAsText"
With xmlhttp
.Open "GET", sUrl, False
.setRequestHeader "Accept", "application/xml;odata=verbose"
.setRequestHeader "Authorization", auth
.send
End With
While Not xmlhttp.readyState = 4
Wend
Debug.Print (xmlhttp.responseText)
Dim oSeqNodes, oSeqNode As IXMLDOMNode
Set oSeqNodes = xmlhttp.responseXML.getElementsByTagName("d:Name")
If oSeqNodes.Length = 0 Then
MsgBox "Could not retrieve information from SharePoint. Please ensure that you have access to the Demand Team Site."
Else
For Each oSeqNode In oSeqNodes
Client.AddItem oSeqNode.Text
Next
End If
End Sub