2

以下是请求参数(url = http://sugarcrm.localhost/service/v4_1/rest.php):

method=get_entry_list&input_type=json&response_type=json
&rest_data {"session":"2q67jvlce802e4htsqc94oshkat9henvicvfclprhrbd8ef6k0o0",
"module_name":"Contacts",
"query":"email1=ychaouche@feeder.fr",
"order_by":"",
"offset":0,
"select_fields":[],
"link_name_to_fields_array":[],
"max_results":0,
"deleted":false}

结果我得到了这个:

"{"name":"Access Denied","number":40,"description":"You do not have access"}"

编辑

每当子查询格式错误时都会触发此错误,不一定是当您无法访问模块时,因此应该注意它。

4

1 回答 1

5

好吧,我的问题的一种解决方案是用这个替换那个查询:

contacts.id 
IN 
(
   SELECT email_addr_bean_rel.bean_id
   FROM   email_addr_bean_rel
   JOIN   email_addresses
   ON     email_addr_bean_rel.email_address_id = email_addresses.id
   WHERE
   email_addresses.email_address = 'ychaouche@feeder.fr'
)   

因为看起来 email1 和 email2 字段是不可查询的(它们不在联系人表中)。解决方法包括通过子查询查询 email_address 表。

编辑:使整个查询看起来像这样:

method=get_entry_list&input_type=json&response_type=json
&rest_data {"session":"2q67jvlce802e4htsqc94oshkat9henvicvfclprhrbd8ef6k0o0",
"module_name":"Contacts",
"query":
"
contacts.id 
IN 
(
   SELECT email_addr_bean_rel.bean_id
   FROM   email_addr_bean_rel
   JOIN   email_addresses
   ON     email_addr_bean_rel.email_address_id = email_addresses.id
   WHERE
   email_addresses.email_address = 'ychaouche@feeder.fr'
)  
"
"order_by":"",
"offset":0,
"select_fields":[],
"link_name_to_fields_array":[],
"max_results":0,
"deleted":false}
于 2012-11-20T15:07:16.940 回答