【问题标题】:SuiteCrm Rest API: JSON Body attributes throws error when calling POST or PUTSuiteCrm Rest API:调用 POST 或 PUT 时 JSON 正文属性引发错误
【发布时间】:2018-11-20 16:11:34
【问题描述】:

我正在使用邮递员来调用 SuiteCRM REST API。

我尝试调用此端点

PATCH http://{{suitecrm-url}}/Api/V8/module

我已将此有效负载添加到正文中(内容类型:应用程序/Json):

{
  "data": {
    "type": "Accounts",
    "id": "3a3ae651-d509-2508-7dc4-5be2e51cc96b",
    "attributes": {
        "name": "name with space"
    }
  }
}

当请求被执行时,SuiteCRM 给出这个响应:

{
  "errors": {
    "status": 400,
    "title": null,
    "detail": "The option \"attributes\" with value array is invalid."
  }
}

我发现问题出在值中的空格:当我尝试使用值“namewithspace”时,它起作用了。

有人知道如何解决这个问题吗?

提前致谢

【问题讨论】:

    标签: rest suitecrm


    【解决方案1】:

    我在 github 上发现了这个问题,解决了我的问题:

    https://github.com/salesagility/SuiteCRM/issues/6452

    简而言之,为了让它工作,我必须修改文件

    /Api/V8/Params/Options/Fields.php
    

    并替换这一行

    const REGEX_FIELD_PATTERN = '/[^\w-,]/';
    

    const REGEX_FIELD_PATTERN = '/[^\w-,\s\]/';
    

    github中提到的人:

    这只是临时修复,不安全升级

    【讨论】:

    • 我想知道是否有某种类型的格式可以在调用中以一种(烦人的)但安全升级的方式解决问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-04
    • 1970-01-01
    • 2019-07-18
    • 1970-01-01
    • 2010-12-10
    相关资源
    最近更新 更多