2012-11-14 164 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);