Sample code for 30+ languages & platforms
Classic ASP Requires Chilkat v11.0.0+

Constant Contact V3: Create a contact list

See more Constant Contact Examples

Create a list with a unique name and a short description. Save the returned list_id with your application’s list record and use it in the membership examples. The new list starts empty. Authorize the app first and use the same credential store.

Constant Contact developer guide

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  Assumes Chilkat is unlocked. See Global Unlock Sample.
set vault = Server.CreateObject("Chilkat.Secrets")
vault.Location = "local_manager"
vault.AutoSplit = 1
set entry = Server.CreateObject("Chilkat.JsonObject")
success = entry.UpdateString("appName","ConstantContactV3")
success = entry.UpdateString("service","OAuth2")
success = entry.UpdateString("username","my-account")
set tokens = Server.CreateObject("Chilkat.JsonObject")
loaded = vault.GetSecretJson(entry,tokens)
If (loaded <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Run the desktop authorization example using this account and store.") & "</pre>"
    Response.End
End If

If (tokens.JsonTypeOf("access_token") <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "The saved authorization has no access token.") & "</pre>"
    Response.End
End If

set http = Server.CreateObject("Chilkat.Http")
http.RequireSslCertVerify = 1
http.AuthToken = tokens.StringOf("access_token")
set resp = Server.CreateObject("Chilkat.HttpResponse")

set body = Server.CreateObject("Chilkat.JsonObject")
success = body.UpdateString("name","Workshop announcements")
success = body.UpdateString("description","People who requested workshop updates")
success = http.HttpJson("POST","https://api.cc.email/v3/contact_lists",body,"application/json",resp)
If (resp.StatusCode = 409) Then
    Response.Write "<pre>" & Server.HTMLEncode( "A conflicting list already exists. Check the existing lists before retrying.") & "</pre>"
    Response.End
End If

If ((success <> 1) Or (resp.StatusCode <> 201)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Expected HTTP 201. Received " & resp.StatusCode) & "</pre>"
    If (resp.StatusCode = 401) Then
        Response.Write "<pre>" & Server.HTMLEncode( "Refresh the saved access token or authorize again.") & "</pre>"
    End If

    Response.End
End If

set created = Server.CreateObject("Chilkat.JsonObject")
success = created.Load(resp.BodyStr)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Expected a JSON response.") & "</pre>"
    Response.End
End If

If ((created.JsonTypeOf("list_id") <> 1) Or (created.StringOfEquals("list_id","",1) = 1)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Missing list_id in the response.") & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Created " & created.StringOf("name") & ". List ID: " & created.StringOf("list_id")) & "</pre>"

%>
</body>
</html>