我试图通过使用Utility.UpdateContactFullForm(authenticationData,联系人)来更新列表中已经存在的联系人);
但是,我收到一条错误消息,声明:远程服务器返回了一个错误:(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);
}
}
}发布于 2012-11-15 20:16:58
我漏掉了以下几点:
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);https://stackoverflow.com/questions/13388327
复制相似问题