恒定联系 - 更新联系人

时间:2012-11-14 22:14:39

标签: c# asp.net constantcontact

我正在尝试使用更新我的列表中已存在的联系人 Utility.UpdateContactFullForm(authenticationData,contact);

但是,我收到一条错误消息,指出: 远程服务器返回错误:(500)内部服务器错误。

描述:在执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息: System.Net.WebException:远程服务器返回错误:(500)内部服务器错误。

来源错误: 在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。

我引用了 ConstantContactBO.dll ConstantContactUtility;

我似乎无法弄清楚问题,非常感谢任何帮助。感谢。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ConstantContactBO;
using ConstantContactUtility;


public partial class hmm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string nextChunkId;
        Contact contact = new Contact();
        //Authentication Data
        AuthenticationData authenticationData = new AuthenticationData();
        authenticationData.Username = "";
        authenticationData.Password = "";
        authenticationData.ApiKey = "";

        // get user Contact List collection
        IList<ContactList> lists = Utility.GetUserContactListCollection(authenticationData, out nextChunkId);

        //Search for Contact By Email
        string x = "a@a.com";
        string[] emailAddress = new string[] { x.Trim() };
        IList<Contact> myList = Utility.SearchContactByEmail(authenticationData, emailAddress, out nextChunkId);

        for (int i = 0; i < myList.Count; i++)
        {
            contact.Id = myList[0].Id;
            contact.FirstName = Server.HtmlEncode("abc");
            contact.LastName = Server.HtmlEncode("def");
            contact.EmailAddress = Server.HtmlEncode("a@a.com");

            ContactOptInList theList = new ContactOptInList();
            theList.OptInSource = ContactOptSource.ActionByContact;
            theList.ContactList = new ContactList("39");
            contact.ContactLists.Add(theList);
              Utility.UpdateContactFullForm(authenticationData, contact);
        }


    }
}

1 个答案:

答案 0 :(得分:0)

我错过了包括以下内容:

 Contact thisContact = Utility.GetContactDetailsById(authenticationData, myContact[0].Id);
           // //Add Lists
            ContactOptInList newList = new ContactOptInList();
            //thisContact.OptInSource = ContactOptSource.ActionByCustomer;
            newList.ContactList = new ContactList("39"); //Contact list you want to add them to
            newList.ContactList = new ContactList("10"); //Contact list you want to add them to
            thisContact.ContactLists.Add(newList);

            //Update contact
            Utility.UpdateContactFullForm(authenticationData, thisContact);