I have not had a chance to look over the new Infusionsoft API SearchService until recently when a friend had some issues getting one of the search results methods to work properly.

Below is the final page that executes the report and writes the fields.

[sourcecode language=”vb”]
<!–#include virtual="/aspxmlrpc/code/xmlrpc.asp" –>
<%

‘key is the encrypted API key you got from Infusionsoft
Dim key
key = "theKey"

‘URL is the API Url you got from Infusionsoft
Dim url
url = "https://theApp.infusionsoft.com:443/api/xmlrpc"

‘The Id of the saved search which should be executed
Dim saveSearchId
savedSearchId = 46

‘The Id of the user for which the search should be executed
Dim userId
userId = 1

‘The results are paged, we will grab the first page
Dim pageNumber
pageNumber = 0

‘The Infusionsoft API function we are calling
Dim apiFunction
apiFunction = "SearchService.getSavedSearchResultsAllFields"

‘The parameter values we are sending to the Infusionsoft API function
Dim apiFunctionParamList
ReDim apiFunctionParamList(4)
apiFunctionParamList(0) = key
apiFunctionParamList(1) = savedSearchId
apiFunctionParamList(2) = userId
apiFunctionParamList(3) = pageNumber

‘Make the API call. The result is an Array of Variants
Dim resultList
resultList = xmlRPC (url, apiFunction, apiFunctionParamList)

If (Not IsEmpty(resultList)) Then

Response.Write "<table>"
Response.Write "<tr>"
Response.Write "<th>Id</th>"
Response.Write "<th>Name</th>"
Response.Write "<th>Company</th>"
Response.Write "<th>Phone</th>"
Response.Write "<th>Email</th>"
Response.Write "<th>Address</th>"
Response.Write "<th>State</th>"
Response.Write "</tr>"

For i = LBound(resultList) To UBound(resultList)
Response.Write "<tr>"
Response.Write "<td>" & resultList(i)("Id") & "</td>"
Response.Write "<td>" & resultList(i)("Name") & "</td>"
Response.Write "<td>" & resultList(i)("Company") & "</td>"
Response.Write "<td>" & resultList(i)("Phone") & "</td>"
Response.Write "<td>" & resultList(i)("Email") & "</td>"
Response.Write "<td>" & resultList(i)("Addr") & "</td>"
Response.Write "<td>" & resultList(i)("State") & "</td>"
Response.Write "</tr>"
Next

Response.Write "</table>"
End If

%>

[/sourcecode]

There were a few changes that had to be made to the ASP XML-RPC library on my machine. The version of the library that I have installed references the Base64Lib.Base64 library does not exist on my server, so I had to find another method for Base64 Encoding and Decoding.

With a bit of googling, I was able to locate a nice post with a few Classic ASP Base64 Encode and Decoder functions.

I added the new functions to the xmlrpc.asp script…

[sourcecode language=”vb”]
Function Base64Encode(inData)

End Function
Function MyASC(OneChar)

End Function

Function Base64Decode(ByVal base64String)

End Function
[/sourcecode]

Once the new functions had been added to the xmlrpc.asp script, I then replace the call to the original Base64 decoding:

[sourcecode language=”vb”]
Case "base64"
set base64=Server.createObject("Base64Lib.Base64")
XMLToValue = base64.Decode(xmlNd.childNodes(0).text)
set base64=nothing
[/sourcecode]

…with a reference to the new function:

[sourcecode language=”vb”]
Case "base64"
XMLToValue = Base64Decode(xmlNd.childNodes(0).text)
[/sourcecode]

Links to the XML-RPC libraries and additional Base64 encoding functions can be found on the Resources page.