Using APIs in code

Occasional Participant

Using APIs in code



We had success running an API from the: Constant Contact v2 API Tester/debugger  (to list our email campaigns). 
When we try and run this in a program (  VB), we get a 401 unauthorized error.


When sending APIs within a program, do we first need to send something that submits our credentials (username and password).

Or would this be included in the API GET?
This is our first attempt with Constant Contact, so any information would appreciated.





The most common reason for getting a 401 error is not including an API Key at the end of the URL you're calling. Can you confirm you're sending all of this information in the API call?



Content-type: application/json

Authorization: Bearer yourAccessToken


If you do think you're sending all of that, could you send me full URL (including the API Key) you're sending a request to, along with your request headers, to




Best Regards,

Shannon Wallace

Partner API Support Engineer

Thanks Shannon,


Yes we sent it with the API_Key. I will send you what we used.

The other areas you listed:  Headers: Content-type: etc.  How do those come into play?  Are these areas in code that need to be defined?


When I run the API in: Constant Contact v2 API Tester/debugger, if I don't supply the Access Token I get an error. :

"error_key": "http.status.unauthorized",
"error_message": "No authentication is present.".   But once I enter the Access Token it runs succesfully.

So could something simular be happening on the code side?  Is there any sample code on the site that shows how to run a Get via code (


Hi Mike,


I sent you an email about this, but just for others who may come across this post in the future, not sending the access token either in the header of the request, or in the URI would have been causing the 401 error. A missing API Key, which should be appended to the URI, could have also caused this, but you were clearly sending the API Key in the URI.


As for the VB question, people can use the , but the examples are written in C# and would thus need to be translated into VB if that's your preferred language.


Best Regards,

Shannon Wallace

Partner API Support Engineer

Thank you Shannon. 

Developer Portal

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

Visit Page