如何在SugarCRM中克服错误40“访问被拒绝 - 您无权访问”?

时间:2012-11-19 15:30:05

标签: api rest sugarcrm

以下是请求参数(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"}"

修改

每当子查询格式错误时都会触发此错误,不一定是当一个人无法访问某个模块时,所以应该知道它。

1 个答案:

答案 0 :(得分: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字段不可查询(它们不在Contacts表中)。解决方法包括通过子查询查询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}