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 = _
ConfigurationManager.ConnectionStrings("2ConnectionString").ConnectionString
Try
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 = "http://api.constantcontact.com/ws/customers/" & 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())
xtr.ReadString()
Dim dsct As New DataSet()
dsct.ReadXml(xtr)
'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.DataBind()
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
HttpContext.Current.Response.Write(ex.Message)
End Try
End Sub
Thank you,
Charles
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("https://api.constantcontact.com/ws/customers/" & ctu, "Basic",
new NetworkCredential((sAPIKey & "%" & ctu), ctp))
theRequest.Credentials = LoginCredentials
It looks like it was simply needing us to change the HTTP to HTTPS.
Thank you,
Charles
The holidays have come and gone. For many seasonal businesses, this means the rush of shoppers has decreased as well. Instead of turning off the lights and waiting for spring, make your email marketi...
See Article