401 error

New Member

401 error

I'm having trouble getting started. I've constructed a basic Http GET for a list of contacts, but it returns a 401 error. Everything looks good to me. Can anyone point out what I'm doing wrong?

Here's some sample code. ColdFusion is my language of choice:

<cfset Variables.username = "{myUsername}" />
<cfset Variables.password = "{myPassword}" />
<cfset Variables.apiKey = "{myAPIkey}" />
<cfset Variables.httpUsername = Variables.apiKey & "%" & Variables.username />

url = "http://api.constantcontact.com/ws/customers/#Variables.username#/contacts"
method = "GET"
username = "#Variables.httpUsername#"
password = "#Variables.password#"
result = "Variables.response"

My only guess at this point, is that since {myUsername} contains spaces, commas, and other special characters, that it's causing a problem in the http call. Do such special characters need to be HTML encoded?
Solution Provider

RE: 401 Error

Another developer had a problem trying to get CfHttp to work. Click here to see that post. They were unable to get it to work because it doesn't support Digest Authentication. They were able to get it to work with CFX_HTTP5

Mike C Support Engineer, Constant Contact

Developer Portal

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

Constant Contact Would Like To Hear From You!

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More