Trying to convert to BASIC VB.NET

Regular Participant

Trying to convert to BASIC VB.NET

No help needed for this, it appears that the only change required is to piont to https and not http.

Here is the code we previously ran fine. It now will not run under the new BASIC. Can anyone tell us why or how to change it to work?

Public Shared Sub GetctctLists(ByRef dropdown As DropDownList)

        Dim ConnectStr As String = _



            Dim ctu As String = Constant_Contact.GetCTU()

            Dim ctp As String = Constant_Contact.GetCTP()

            'check if user has ct's

            If String.IsNullOrEmpty(ctu) Then

                Exit Sub

            End If

            If String.IsNullOrEmpty(ctp) Then

                Exit Sub

            End If

            'this returns an xml list of lists for the ctct account.

            Dim sUri As String = "" & ctu & "/lists"

            Dim sAPIKey As String = "Dev Code Here"

            'setup httpWebReqeust to send the request

            Dim address As New Uri(sUri)

            Dim theRequest As HttpWebRequest = TryCast(WebRequest.Create(address), HttpWebRequest)

            theRequest.Credentials = New NetworkCredential((sAPIKey & "%" & ctu), ctp)

            theRequest.Method = "GET"

            theRequest.ContentType = "application/vnd.ctct+xml"

            Using theResponse As HttpWebResponse = TryCast(theRequest.GetResponse(), HttpWebResponse)

                'load dataset with xml response

                Dim xtr As New XmlTextReader(theResponse.GetResponseStream())


                Dim dsct As New DataSet()


  'Filter out unwanted lists

                Dim dataView As DataView = dsct.Tables("ContactList").DefaultView

                dataView.RowFilter = "ShortName Not like 'Active' And ShortName Not like 'Do Not Mail' And ShortName Not like 'Removed' "

                'load dropdown list with list names from name xml node

                dropdown.DataSource = dataView

                dropdown.DataTextField = "ShortName"

                dropdown.DataValueField = "id"


                dropdown.Items.Insert(0, "")

                'Create the xml file to check what we are receiving.

                '   ds.WriteXml("C:\Data.xml")

            End Using

        Catch ex As Exception


        End Try

    End Sub

Thank you,



It should be a simple change to setting up the credentials of your request.  Change the following code:


theRequest.Credentials = New NetworkCredential((sAPIKey & "%" & ctu), ctp)


To set up a LoginCredentials class which allows you to specify the base domain and the authentication type:


dim LoginCredentials = new CredentialCache()

LoginCredentials.Add("" & ctu, "Basic",

                new NetworkCredential((sAPIKey & "%" & ctu), ctp))

theRequest.Credentials = LoginCredentials

Dave Berard
Senior Product Manager, Constant Contact
Regular Participant

It looks like it was simply needing us to change the HTTP to HTTPS.


Thank you,


Developer Portal

View API documentation, code samples, get your API key.

Visit Page