【问题标题】:Getting null response when passing select field array in SugarCRM在 SugarCRM 中传递选择字段数组时获得空响应
【发布时间】:2016-07-27 07:27:16
【问题描述】:

我正在尝试使用 rest API v4_1 从 Sugar-CRM 获取条目。 当我尝试在 select_fields 中传递值时,我得到空响应.. 当我传递空的 select_fields 数组时,我得到了成功的响应..

这是我的代码

    var settings = {
  "async": true,
  "crossDomain": true,
  "url": "http://mycrm.com/service/v4_1/rest.php",
  "method": "POST",
  "headers": {
    "cache-control": "no-cache",
    "postman-token": "e85b8af0-3234-45c8-f5ec-abe8xx4d6efd",
    "content-type": "application/x-www-form-urlencoded"
  },
  "data": {
    "method": "get_entry",
    "input_type": "json",
    "response_type": "json",
    "rest_data": "{\"session\":\"xxyyxxsmkdemnmdm1212\",\"module_name\":\"Accounts\",\"id\":\"12345-6789-1214-1234\",\"select_fields\":{},\"link_name_to_fields_array\":{ }, \"track_view\":true}"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

当我在 select_fields 中传递空数组时,上面的代码成功地给了我响应..

注意:我在上面更改了我的会话、ID、邮递员令牌。这些不是实际值。

【问题讨论】:

  • 您在 select_fields 中要求什么值?
  • 我只想传递 select_fields 中的特定字段,例如id,first_name,last_name

标签: arrays web-services sugarcrm


【解决方案1】:

查看service/v3_1/SugarWebServiceImplv3_1.php 那里定义了用于 api v4.1 的函数 get_entry。据我所知,您应该传递一个字段数组。

它们稍后会在 service/core/SoapHelperWebService.php 的函数 get_name_value_list_for_fields 中被 foreach 处理。

试试 'select_fields':['id', 'name', ...]

【讨论】:

  • Thanxx 兄弟..你是 grt man...它就像魔术一样..实际上我正在传递“{}”然后我尝试了你的方法“[]”...它有效..
猜你喜欢
  • 2018-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-06
相关资源
最近更新 更多