【问题标题】:Upload REST API shows 400 bad request上传 REST API 显示 400 错误请求
【发布时间】:2020-10-31 06:26:30
【问题描述】:

我有一个 ESB 网络服务客户端,它使用以下 RestAPI 将文档上传到 Alfresco。

http://:8080/alfresco/service/api/upload

我明白,API 被称为多部分/表单数据,带有文件和必填字段。当我执行时,我得到了以下错误响应。

{
  "status": {
    "code": 400,
    "name": "Bad Request",
    "description": "Request sent by the client was syntactically incorrect."
  },
  "message": "Required parameters are missing",
  "exception": "",
  "callstack": [],
  "server": "Enterprise v5.2.3 (r852994b1-b12) schema 10,065",
  "time": "10-Jul-2020 12:26:47"
}

我使用 WSO2 ESB 客户端,ESB 代码看起来都不错。我唯一可以调试的地方是通过 wirelog 。 Wirelog 显示一切都很好(请参阅下面的屏幕截图)。错误消息包含相互冲突的信息,例如

"description": "客户端发送的请求在语法上不正确。" "message": "缺少必需的参数",

我是否可以从 Alfresco 服务器端获取日志来确定实际问题是什么,哪个语法不正确? 缺少什么参数?

如下图线日志截图

please click this link to see image of wiretap

【问题讨论】:

  • 你检查你的alfresco.log服务器上的文件了吗?
  • 是的 alfresco.log 没有任何与服务相关的日志。我可能需要启用此日志吗?

标签: wso2 wso2esb alfresco alfresco-enterprise


【解决方案1】:

您关注哪些文档?通过快速浏览这里,我会说您并没有发送您应该发送的所有内容: https://docs.alfresco.com/5.0/references/RESTful-UploadUploadPost.html

这是您看到的触发条件,因此我会更仔细地查看您实际发送的内容。也许使用 Fiddler 或一些类似的软件来记录您的请求并进行检查。

// Ensure mandatory file attributes have been located. Need either destination, or site + container or updateNodeRef
      if ((filename === null || content === null) || (destination === null && (siteId === null || containerId === null) && updateNodeRef === null))
      {
         exitUpload(400, "Required parameters are missing");
         return;
      }

此外,可以在此处找到相关的 Web 脚本,它是在 JS 中实现的,因此添加额外(临时)日志记录相对容易。

...alfresco\tomcat\webapps\alfresco\WEB-INF\lib\alfresco-remote-api-5.0.d.jar\alfresco\templates\webscripts\org\alfresco\repository\upload\

【讨论】:

  • 正如我所提到的,我正在发送所有需要的参数。相同的参数可以在其他 Rest 客户端上正常工作。有没有办法获取休息服务的日志?或者我正在传递的有效载荷,以便我知道缺少哪一个。
  • 看看更新的答案,也许会有帮助。祝你好运! :)
  • 您好,谢谢,您的 cmets 帮助我了解了哪些领域正在通过,哪些领域没有通过等等。但是有没有办法知道 Alfresco 使用任何日志配置收到的原始 HTTP 请求?
  • 您也可以设置 Tomcat 访问日志来记录参数和正文,但这不是开箱即用的。
【解决方案2】:

您可以使用 api-explorer rest api 上传文档。

https://api-explorer.alfresco.com/api-explorer/#!/nodes/createNode

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-13
    • 1970-01-01
    • 2015-10-20
    • 1970-01-01
    • 2013-03-12
    • 1970-01-01
    • 1970-01-01
    • 2019-06-30
    相关资源
    最近更新 更多