c# Getting Started

Regular Participant

c# Getting Started

I pulled down the samples from GitHub for C# and visual studio.  I went through the steps of getting a mashery account, access token, api key and shared secret.  I used the test page and had no issues.  In app.config it's asking for 

 

<add key="APIKey" value=""/>
<add key="Password" value=""/>
<add key="Username" value=""/>
<add key="RedirectURL" value=""/>

 

The APIKey is straightforward.  However, I am not clear on what password, username and redirect url to use?  I've tried various combinations to no avail.  I end up getting this error when I run the programs

 

CtCTException Thrown:

Error Message: http.status.unauthorized:No authentication is present 

 

 

13 REPLIES 13
Member

Hi Todd,

 

I was able to reply to your email about this, but I also wanted to share here for anyone else who may have questions.

 

Based on what you've provided it looks like you're using a notably older version of the SDK that likely will not function any longer. How did you obtain the version of the .NET code that you're currently working with?

For reference, the most up-to-date code can be found here: https://github.com/constantcontact/.net-sdk


As an additional note, the examples in the SDK use OAuth to connect with the API and obtain an Access Token, but if you are building an integration for a single Constant Contact account, you can simply store your Access Token in your application configuration and use it directly, rather than using the OAuth methods to get the access token.

Please let me know if you have any questions!

 

Sincerely,

Elijah G.
API Support Engineer

Thanks can you give the example of where I put my credentials for my single account so I don't get the user name /password when i run these samples?

 

The original code I obtained I found here https://developer.constantcontact.com/libraries/sample-code.html

Hello,

 

With the most up-to-date versions of these samples, they should not ask for or require the username/password. Instead they make use of the OAuth client flow to get an Access Token. If you're looking to store the credentials for a single account in your application config, you can generate Access Tokens using our API tester here: https://constantcontact.mashery.com/io-docs. Once you have a token for the desired account, you can store that token and your API Key.

 

Please note that this process is only appropriate when connecting a single account. For any integrations that need to be able to serve many accounts, OAuth should always be used so that the users are not required to go through steps designed for developers.

 

Please let me know if you have any follow-up questions!

 

Sincerely,

Elijah G.
API Support Engineer
Occasional Participant

I've downloaded the GitHub project and successfully built and obtained the CTCT.DLL.

 

However I'm completely missing the ConstantContact Class and all its methods. All the others are there. I see in the development branch is there. Did this get pulled out for something else? If so the documentation and samples and everything is old / wrong now. 

 

Therefore I cannot really use it at all! 

 

Error 8 Type 'CTCT.ConstantContact' is not defined.

 

I can use the DLL to build all the objects like below, but the main method to connect to the endpoints is not there!. 

 

 

 

Dim contact As New Contact()
' Don't care about the id value
contact.Id = 1
contact.Status = Status.Active
contact.FirstName = row("FirstName")
contact.LastName = row("LastName")
contact.Addresses.Add(New Contacts.Address With {.Line1 = row("Address").ToString,
.City = row("City").ToString, .StateName = row("st").ToString, .PostalCode = row("ZipCode").ToString, .AddressType = "PERSONAL"})


Dim addy As New EmailAddress()

addy.EmailAddr = row("email").ToString
addy.ConfirmStatus = ConfirmStatus.NoConfirmationRequired
addy.Status = Status.Active
addy.Id = 1

 

 


6-7-2016 4-26-11 PM.jpg
Occasional Participant

BUMP

Hello,

 

My apologies for not getting you an answer on this sooner! After a bit of checking, it looks like the current docs hosted on github.io are for a notably outdated version of the .NET SDK and are not currently a valid guide. I will be looking to see what can be done to get this resolved, but it may be a bit before the new docs will be available. In the immediate term I would advise looking at the samples provided in the SDK for guidance.

 

If you run into any problems while building or have any questions about the SDK, you can also post a topic here on the forums and I'll be happy to help!

 

Sincerely,

Elijah G.
API Support Engineer
Occasional Participant

Thanks for confirming this and I'll go ahead and use the samples for reference, just wanted to make sure that I wasn't missing something obvious!

 

 

Any progress on new DOC's  Git is still show Old samples

Hello,

 

Because our team is devoting most of our resources to building out the new V3 version of our API, this documentation is not likely to be updated or worked on in the short term. Having said that, we do still have current examples in the Readme on github, including how to generate or create a service object using the ConstantContactFactory.

 

Please let me know if you have any other questions!

 

Sincerely,
David B.
API Support Specialist

Hi guys,

 

As you plan to migrate to V3, can you confirm that the existing API  version will remain available and working ?

 

Hello,

 

Thank you for reaching out to Constant Contact API Support.

 

The plan will be to eventually retire our V1 and V2 API versions as we move users over to V3. While I don't have a specific timeframe I can provide quite yet, we will be sure to announce an end-of-life plan for any legacy APIs so that everyone has enough time to plan and develop new integrations using the V3 API.

 

Please let me know if you have any other questions!

Sincerely,
David B.
Tier II API Support Engineer

 

 

I am trying to incorporate your api into my clients current signup form.

We want to create a new contact with each form submission (unless email already in constant contact)

I'll be posting to a single constant contact account so does that mean I don't need the .net sdk?

can i just post directly to api in webrequest with all the persons data as parameters.

 

cant seem to find any examples of just the api url with parameters etc.

 

Do i just pass access token as part of the api post?

 

Any examples for .net (not the html form), but c# httpwebrequest or similar.

Hi @SamanthaL66,

 

Looks like you also emailed us this request and I've replied there, but I'll give a brief answer here for anyone else who may come across this.

 

The base answer for this request is yes. The problem was that the Access Token was not being submitted in the HTML header. It needs to be submitted in the header as a Bearer token. If that is done then you can just submit the API calls as an HTTP request similar to how our API Tester page works. https://constantcontact.mashery.com/io-docs


Regards,
Jimmy D.
Tier II API Support Engineer
Developer Portal

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

Visit Page