Run a Saved Report with Infusionsoft API and Classic ASP

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 = ""

‘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>"

Response.Write "</table>"
End If



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

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

…with a reference to the new function:

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

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

By | 2014-08-26T12:15:02-05:00 May 13th, 2011|Categories: API, Infusionsoft|Tags: |0 Comments

About the Author:

Brad Ullery started off a little different – he was a jock in high school and college, and he found that he could talk to machines as easily as he could swing a bat. He spent years honing his craft, and has never met a technology he didn’t like (although there are some he prefers). A father or three amazing kids, a husband to an amazing wife, a baseball and hockey fan, Brad now spends his time architecting solutions designed to do one thing – deliver results.