我正在 C# 中使用 SugarCRM 的 SOAP API 客户端。 我在我的 Windows 应用程序中添加了 SugarCRM 的 Web 引用。 我需要获取在特定时间戳之前创建的潜在客户列表。为此,我这样做:
try
{
//Fields to retrieve
string[] Lead_fields = new string[] { "id", "name", "phone_home", "phone_mobile", "phone_work", "phone_other", "phone_fax", "deleted" ,"gclid_c"};
LastSyncDateTime = ReadLastSyncDateTime();
DateTime dtTemp = TimeZone.CurrentTimeZone.ToUniversalTime(Convert.ToDateTime(LastSyncDateTime));
string sDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", dtTemp);
string L_date_created = sDate; //LastSyncDateTime;
string Leads_query = "(Leads.date_modified <= " + L_date_created + ") AND Leads.deleted = 0";
//As on 2014.11.07 (getting exception : Access Denied)
SugarCRM.get_entry_list_result_version2 Leads_result = SugarClient.get_entry_list(SessionId, "Leads", Leads_query, "", 0, Lead_fields, null, 30, 0, true);
if (Leads_result.entry_list.Count() > 0)
{
for (int i = 0; i < Leads_result.entry_list.Count(); i++)
{
MyLeads newLead = new MyLeads();
newLead.LeadId = Leads_result.entry_list[i].name_value_list[0].value;
MyLeadsList.Add(newLead);
}
}
}
catch (Exception ex)
{
LogMessageToFile("ERROR : " + ex.Message.ToString());
}
请注意,我能够以管理员身份成功登录。 请帮忙解决这个问题。
最佳答案
我成功了。没有任何可用的文档可以引导您走向正确的方向,但我只是做了一个猜测,并且它有效。
我刚刚引用了 L_date_created
字段。
因此查询将如下所示:
string Leads_query = "(Leads.date_entered <= '" + L_date_created + "') AND Leads.deleted = 0";
哇哦!它正在工作..
关于c# - 在 C# 中的 SugarCRM SOAP API 中使用查询时获取 "Access Denied",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24710567/