I'm trying to put together a macro that will access a site's API and download files.
First, it accesses the site and searches for a particular document. If it is found, the site returns various information about the document, one item being the 'view_address', which is the url to view or download the document. Below is part of the code. It seems to work down to just before the MSXML2.DOMDocument60 portion. So, the Debug.Print WHttp.responseText returns all the information about my particular document.
Next, I need to get the url link that is at "view_address", as seen in the below snippet of what is returned at WHttp.responseText.
],
"images": [
{
"number": 5294136,
"book": "000692",
"page": "0347",
"view_address": "\/api\/v1\/images?city=NYC&number=5294136&action=view"
I'm trying to load this information so that the portion I want can be extracted, but xmlDoc.LoadXML(SearchResponse) does not work. The Msgbox "Load Error" shows and it appears that xmldoc is blank.
Clearly I'm stumbling around and don't know what I'm doing, but can anyone offer any ideas of what I'm doing wrong?
Thanks in advance.
First, it accesses the site and searches for a particular document. If it is found, the site returns various information about the document, one item being the 'view_address', which is the url to view or download the document. Below is part of the code. It seems to work down to just before the MSXML2.DOMDocument60 portion. So, the Debug.Print WHttp.responseText returns all the information about my particular document.
Next, I need to get the url link that is at "view_address", as seen in the below snippet of what is returned at WHttp.responseText.
],
"images": [
{
"number": 5294136,
"book": "000692",
"page": "0347",
"view_address": "\/api\/v1\/images?city=NYC&number=5294136&action=view"
I'm trying to load this information so that the portion I want can be extracted, but xmlDoc.LoadXML(SearchResponse) does not work. The Msgbox "Load Error" shows and it appears that xmldoc is blank.
Clearly I'm stumbling around and don't know what I'm doing, but can anyone offer any ideas of what I'm doing wrong?
Thanks in advance.
Code:
WHttp.Open "GET", FullSearchPath, False
'WHttp.setRequestHeader "Authorization", "Basic " & APIToken
WHttp.SetCredentials APIToken, APIToken, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
WHttp.send
SearchResponse = WHttp.responseText
Debug.Print WHttp.responseText
Dim xmlDoc As New MSXML2.DOMDocument60
If Not xmlDoc.LoadXML(SearchResponse) Then
MsgBox "Load Error"
End If