cancel
Showing results for 
Search instead for 
Did you mean: 
Constant Contact wants to help you succeed! We’re celebrating our professional service programs on the Constant Contact Community this month and you have a chance to try one of the services for free! Learn more.

Java API: import com.constantcontact.ConstantContact cannot be resolved

Occasional Contributor

Java API: import com.constantcontact.ConstantContact cannot be resolved

Hi,

I'm trying to get started with the Java API.

I downloaded the Java SDK.

I installed the Eclipse Maven Plugin and imported the files using the Maven POM file.

 

All of the files in src/main/java appear to validate fine.

 

When I try to write the example given in the readme file it doesn't recognize the ConstantContact library, giving the error message: The import com.constantcontact.ConstantContact cannot be resolved.

 

I added a new package at the end of the packages in the src/main/java folder, after com.constantcontact.webhooks.model package.  From there I added a new class with the following code:

 

package JGL;

import com.constantcontact.components.Component;

import com.constantcontact.ConstantContact;

 

 

public class Run {

public static void main(String[] args){

ConstantContact constantContact = new ConstantContact("api", "token");

Contact contact = constantContact.getContact(2);

}

}

 

Note that Eclipse does recognise the components.Component library. 

 

Any ideas on why I can't get this to work?

 

Thanks!

Jon

 

2 REPLIES 2
Occasional Contributor

Re: Java API: import com.constantcontact.ConstantContact cannot be resolved

It occured to me that since the other library imports fine, maybe the sdk has changed since the original readme post.  I dug into the code and got this to work:

 

import com.constantcontact.components.contacts.Contact;

import com.constantcontact.exceptions.service.ConstantContactServiceException;

 

 

public class Run2 {

public static void main(String[] args){

String api = "api";

String token = "token";

 

ContactService cs = new ContactService(token,api);

 

Contact c = new Contact();

try{

c =cs.getContact("2");

}

catch(ConstantContactServiceException ccse) {

 

}

System.out.println(c.getFirstName());

 

Must be the that the original examples no longer work.

 

Thanks,

Jon

Honored Contributor

Re: Java API: import com.constantcontact.ConstantContact cannot be resolved

Hello,

 

My apologies for the delayed response! What you observed about changes in the SDK is correct! There was a major update to the SDK that was designed to move towards a proper service based SDK, rather than relying on a very large and difficult to read master class. The sample code included with the SDK on our github repo has also been updated and can be used as a reference if needed.

 

If you have any questions about using the updated SDK, please feel free to ask!

 

Sincerely,

Elijah G.
API Support Engineer