Since SmartConnect 2015 we’ve been able to connect to a variety of REST services using the REST connector.  This requires the service to provide a JSON or XML payload.  I recently came across a service that doesn’t use JSON or XML.  The GoToWebinar Admin API will only give back an Excel file, so I could not use the built-in REST connector in SmartConnect.  The REST service essentially gives you the same file as if you logged into the GoToWebinar interface and manually exported the data you need.  Using the REST service to automatically go pull down the latest Excel file will eliminate the need to manually go create an excel file when you need to run a map.

Since the current REST connector in SmartConnect will not handle this response we will have to write a pre-map task script to call the web service and save the Excel file.  The following vb.net script will connect to the GoToWebinar Admin API, but you could modify it to connect to any web service that provides an Excel file.  This web service only requires the Authorization parameter, but other services may require additional parameters to take into consideration.

Dim header As New System.Net.WebHeaderCollection() ‘create header

header.Add(“Authorization: Your_Authorization_Token”) ‘add token to header

Dim sUrl As String = “https://api.getgo.com/admin/rest/v1/accounts/Your_Account_Number/users/reports/webinar/recording/registrant?fromDate=Your_epochfromdate&toDate=Your_epochtodate ‘endpoint to call

Dim request As System.Net.HttpWebRequest = TryCast(System.Net.WebRequest.Create(New Uri(sUrl)), System.Net.HttpWebRequest)

request.Headers = header

request.Accept = “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”

request.Method = “GET”

Dim response As System.Net.WebResponse = request.GetResponse()

Dim o As Stream = response.GetResponseStream()

Using fs = File.Create(“c:Your_Save_LocationYour_Excel_Filename.xlsx”) ‘create excel output

  o.CopyTo(fs)

End Using

You will need to provide your Authorization Token, Account Number, from and to dates (in Epoch milliseconds), and export path/name for the script to work correctly with your data.  When the pre-map task script is properly setup it will look similar to this:

With the script in place, you can now continue the map setup and will be able to choose this Excel file as the source for the map.  Note: You will need to have a placeholder Excel file to choose as a source file if this will be the first time setting up the map since the file from the pre-map task will not be available until the map is actually run.

This should get you started with a web service that returns an Excel file response.  In this particular example, I would recommend using a couple global variables for the from and to dates that are calculated before this pre-map task.   This will prevent the need to change the dates in the script for future use and make it more dynamic.