cancel
Showing results for 
Search instead for 
Did you mean: 

AddRemoveContactsFromListsActivity() usage?

SOLVED
Occasional Contributor

AddRemoveContactsFromListsActivity() usage?

Attempting to delete emails from a contact list(s).  having no success when executing the following via the .NET wrapper APIs:

 

Dim actSrvc As New CTCT.Services.ActivityService

Dim actSrvcRsp As New CTCT.Components.Activities.Activity

 

actSrvcRsp =  actSrvc.AddRemoveContactsFromListsActivity(

  accessToken:=myAccessToken

, apiKey:=myAPIKey

, emailAddresses:=myEmailsList

, lists:=myListsList    )

 

myEmailsList has 23 items. 

myListsList has 1 item.

 

This seems to execute ok. But i have seen no contacts removed from the list of contact lists i submit.  and when i check results later using GetActivty( idOfTheActivity ), it always showsErrorCount = 1 And Errors(0):   emailAddress = "";    lineNumber = 0;     message = "sameEmailEverytime@junk.com"

 

Can you see what i am doing wrong, or neglecting to do?   Thanks in advance for any feedback:)

5 REPLIES 5
Moderator

Re: AddRemoveContactsFromListsActivity() usage?

Can you provide your username for us to look into this closer?  You can either PM it to me or send it to our support staff via webservices@constantcontact.com

Dave Berard
Senior Product Manager, Constant Contact
Occasional Contributor

Re: AddRemoveContactsFromListsActivity() usage?

PM sent.  Thank you.

Moderator

Re: AddRemoveContactsFromListsActivity() usage?

Thanks for sending that over.  Looked at your account and confirmed our suspicions.  You are on our new Contact management system, which is an upgrade we're rolling out to our customer base over the next few months and which started about 3 months ago to migrate everyone.  This new system allows for a lot more flexibility and features when editing contacts.

 

Unfortunately, we ran into an issue where Contacts are not being removed correctly with bulk activity requests from lists.  We are investigating this issue, however it is a very complicated problem.  We are continuing to work on it and will update once we have a solution.  As of this time, we don't have any workarounds to share.

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Contributor

Re: AddRemoveContactsFromListsActivity() usage?

Has there been any better resolution on this issue?  I seem to be hitting this as well.

Occasional Contributor

Re: AddRemoveContactsFromListsActivity() usage?

It turns out that the JSON data is not formed correctly.  I did figure this out finally.  I modified the AddRemoveContactsFromListsActivity() method in the ActivityService.cs file as below. (see //TG marks)

 

 

/// <summary>

/// Create a Remove Contacts From Lists Activity.

/// </summary>

/// <param name="accessToken">Constant Contact OAuth2 access token.</param>

/// <param name="apiKey">The API key for the application</param>

/// <param name="emailAddresses">List of email addresses.</param>

/// <param name="lists">List of id's.</param>

/// <returns>Returns an Activity object.</returns>

public Activity AddRemoveContactsFromListsActivity(string accessToken, string apiKey, IList<string> emailAddresses, IList<string> lists)

{

    Activity activity = null;

    string url = String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.RemoveFromListsActivity);

 

    //TG

    IList<ImportEmailAddress> importData = new List<ImportEmailAddress>();

    foreach (string emailAddress in emailAddresses)

    {

        importData.Add(new ImportEmailAddress() { EmailAddresses = new List<string> { emailAddress } });

    }

    //TG

 

    RemoveContact removeContact = new RemoveContact()

    {

        //ImportData = new List<ImportEmailAddress>() { new ImportEmailAddress() { EmailAddresses = emailAddresses } },

        ImportData = importData, //TG

        Lists = lists

    };

 

    string json = removeContact.ToJSON();

    CUrlResponse response = RestClient.Post(url, accessToken, apiKey, json);

 

    if (response.IsError)

    {

        throw new CtctException(response.GetErrorMessage());

    }

 

    if (response.HasData)

    {

        activity = response.Get<Activity>();

    }

 

    return activity;

}

 

 

Thanks,

Tony

Tags (2)