Use WebAPI to Retrieve a Data List

For more background information about Infinity Web APIs, see:

Introduction to the Infinity Web Service APIs

Or a for a more in depth discussion, see:

API Overview

This example is from the WebAPIDemo that comes with samples when you install the Infinity SDK.

The WebAPIDemo project has the following references:

Search is called to retrieve a constituent, and a constituent ID is retrieved from the search results. LoadRecord is called with the constituent ID that uses the WebAPI to retrieve a data list and populate a list view on a win form.

Private Sub LoadRecord(ByVal ID As Guid) 'load the phone numbers using the "Phones List" data list from Blackbaud.AppFx.Constituent.Catalog
       InitAppFxService()
        LoadPhones(ID)
        LoadEmail(ID)
End Sub
 
   Private Sub LoadPhones(ByVal contextID As Guid)
 
       InitAppFxService()
 
       With lv_Phones
            .View = View.Details
            .FullRowSelect = True
           .Clear()
        End With
 
       Try
            Dim req As New ServiceProxy.DataListLoadRequest
            With req
                .ClientAppInfo = GetRequestHeader()
                .DataListID = New Guid("846e0526-3b1e-4d4e-a973-1be20ecb8288")  ‘The guid  (System record id) is a reference to a data list feature which can be determined by using the feature meta data. 
               .ContextRecordID = contextID.ToString
                .IncludeMetaData = True
            End With
 
           Dim reply As ServiceProxy.DataListLoadReply
            reply = _service.DataListLoad(req)
 
           If (reply.Rows Is Not Nothing) Then
                For Each f As Blackbaud.AppFx.XmlTypes.DataListOutputFieldType In reply.MetaData.OutputDefinition.OutputFields
                    lv_Phones.Columns.Add(f.Caption)
                Next
 
               For Each row As ServiceProxy.DataListResultRow In reply.Rows
                    lv_Phones.Items.Add(New ListViewItem(row.Values))
                Next
 
              lv_Phones.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
            End If
 
          MouseWaitStop()
 
       Catch exSoap As System.Web.Services.Protocols.SoapException
            'If an error occurs we attach a SOAP fault error header.
            'You can check the proxy.ResponseErrorHeaderValue to get rich
            'error information including a nicer message compared to the raw exception message.
           Dim wsMsg As String
            If _service.ResponseErrorHeaderValue Is Not Nothing Then
               wsMsg = _service.ResponseErrorHeaderValue.ErrorText
            Else
               wsMsg = exSoap.Message
            End If
           MouseWaitStop()
           MsgBox(wsMsg)
 
       Catch ex As Exception
            MouseWaitStop()
            MsgBox(ex.Message)
 
       End Try
 
   End Sub
 
   Private Sub LoadEmail(ByVal contextID As Guid)
 
       InitAppFxService()
 
       With lv_Email
            .View = View.Details
            .FullRowSelect = True
           .Clear()
        End With
 
       Try
            Dim req As New ServiceProxy.DataListLoadRequest
            With req
                .ClientAppInfo = GetRequestHeader()
                .DataListID = New Guid("9A688911-B64E-4833-B39F-730472ACD9EB")
                .ContextRecordID = contextID.ToString
                .IncludeMetaData = True
            End With
 
           Dim reply As ServiceProxy.DataListLoadReply
            reply = _service.DataListLoad(req)
 
           If (reply.Rows Is Not Nothing) Then
               lv_Email.View = View.Details
                For Each f As Blackbaud.AppFx.XmlTypes.DataListOutputFieldType In reply.MetaData.OutputDefinition.OutputFields
                    lv_Email.Columns.Add(f.Caption)
                Next
 
               For Each row As ServiceProxy.DataListResultRow In reply.Rows
                    lv_Email.Items.Add(NewListViewItem(row.Values))
                Next
 
              lv_Email.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
            End If
 
          MouseWaitStop()
 
       Catch exSoap As System.Web.Services.Protocols.SoapException
            'If an error occurs we attach a SOAP fault error header.
            'You can check the proxy.ResponseErrorHeaderValue to get rich
            'error information including a nicer message compared to the raw exception message.
           Dim wsMsg As String
            If_service.ResponseErrorHeaderValue Is Not Nothing Then
               wsMsg = _service.ResponseErrorHeaderValue.ErrorText
            Else
               wsMsg = exSoap.Message
            End If
           MouseWaitStop()
            MsgBox(wsMsg)
 
       Catch ex As Exception
            MouseWaitStop()
            MsgBox(ex.Message)
 
       End Try
 
   End Sub
 
 
 
Private Sub InitAppFxService()
 
       'Set the url of the web service
        _service.Url = txt_ServiceUrl.Text
 
       'Must set credentials since we use Windows authentication.
        _service.Credentials = System.Net.CredentialCache.DefaultCredentials
End Sub
 
 
 
Private Function GetRequestHeader() As ServiceProxy.ClientAppInfoHeader
        'Create the client app header (all requests require this)
        Dim header As New ServiceProxy.ClientAppInfoHeader
 
       'Provide some name to distinguish this application using the service. This name will ultimately be passed to the
        'database, so don't make this random or per user or you won't benefit from connection pooling.
        header.ClientAppName = txt_ApplicationName.Text
 
       'A single webservice instance can serve multiple databases.
        'You must specify the database for every request. The list of available databases is what you see in the login form.
        header.REDatabaseToUse = cbo_Databases.Text
 
       Return header
End Function