2012-11-14 188 views
0

我想通过使用 Utility.UpdateContactFullForm(authenticationData,contact);更新我的列表中已存在的联系人。常量联系人 - 更新联系人

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

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

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

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

我引用了ConstantContactBO.dllConstantContactUtility;

我似乎无法找出问题,任何帮助,非常感谢。谢谢。

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 = "[email protected]"; 
     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("[email protected]"); 

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


    } 
} 

回答

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); 
相关问题