Discourse Drafts api 无法工作

在使用 Spring Boot 实现 drafts API 时,我遇到一个问题。所有 API 都工作正常,但这个 API 给了我很大的麻烦,我无法理解问题所在。

有人实现过这个功能,能指导我解决这个问题吗?我将我能捕获到的异常错误放在下面:

2023-05-15 15:09:44.310 ERROR 880 --- [nio-5000-exec-1] c.b.c.e.advice.ExceptionHandlerAdvice    :  ** Exception Leaked & captured : JsonParseException; Unrecognized token 'Optional': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"Optional[java.nio.HeapByteBuffer[pos=0 lim=16187 cap=16187]]"; line: 1, column: 9]
2023-05-15 15:09:44.315 DEBUG 880 --- [nio-5000-exec-1] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request
com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Optional': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

这是有效负载和 URL “/drafts.json”:

{
    "draft_key": "new_topic",
    "sequence": 94,
    "data": {
        "reply": "estaetwetweas sfasdf asdfa sdf as ",
        "action": "createTopic",
        "title": "test test test",
        "categoryId": 5,
        "archetypeId": "regular",
        "metaData": null,
        "composerTime": 19025,
        "typingTime": 4800
    }
}
1 个赞

我喜欢稍微摆弄一下 API,并快速看了一下,但 Insomnia 返回了 500 错误。:confounded:

我使用管理员 API 密钥和 Insomnia 上的以下载荷,在 /drafts.json 上进行 POST 请求:

{
  "draft_key": "new_topic",
  "sequence": 181,
  "data": {
    "reply": "test draft",
    "action": "createTopic",
    "title": "Here's a draft topic again",
    "categoryId": 4,
    "archetypeId": "regular",
    "metaData": null,
    "composerTime": 11311,
    "typingTime": 3200
  },
  "owner": "fa8073ea509544319371333121ca878e",
  "force_save": false
}

如果我进行“回复”草稿请求,也会收到相同的 500 错误。

抱歉我帮不上忙,但我现在也想知道为什么它不起作用。:technologist: :grey_question:

我一定会在此更新解决方案。感谢您的尝试,如果您能比我更快地修复它,请在此处更新,以便我也能从您的努力中受益。

1 个赞

大家好,我只是想补充一下,我也遇到了完全相同的问题(尝试使用相同的逆向工程负载发布到 draft.json),我想知道你们是否找到了通过 API 将草稿写入帖子的解决方案或变通方法。谢谢!