用于添加所有者的Rest API已停止工作

我以前使用 REST API 来更新群组的所有者。现在这似乎已停止工作(尽管群组确实存在):

Method: PUT, RequestUri: 'https://forums.mysite.uk/admin/groups/1949/owners', Version: 1.1, Content: System.Net.Http.FormUrlEncodedContent, Headers:
{
  Api-Key: <redacted>
  Api-Username: admin
  Accept: application/json
  User-Agent: BasecampGatewayLive
  Content-Type: application/x-www-form-urlencoded
}:
{
  "group": {
    "usernames": "kay"
  }
}
StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Server: nginx/1.22.1
  Date: Thu, 23 Jan 2025 02:03:44 GMT
  Transfer-Encoding: chunked
  Connection: keep-alive
  Vary: Accept-Encoding
  Vary: Accept
  X-Request-ID: 8e5dcf66-c4e0-4d4f-a382-dacb774691c3
  X-Runtime: 0.004369
  Strict-Transport-Security: max-age=31536000; includeSubDomains
  Content-Type: application/json; charset=utf-8
}
{"errors":["The requested URL or resource could not be found."],"error_type":"not_found"}

这以前运行正常,但 Discourse 的一次升级似乎破坏了它。由于 Discourse API 页面中不包含此 API,因此我不确定如何找出发生了什么变化。

许多端点并未被记录,但您可以轻松地 Reverse engineer the Discourse API 进行反向工程。

对我来说,该请求在最新的 Discourse 版本上运行正常:

我猜你的 API 密钥已失效。

我也考虑过,但无效的密钥或用户名通常会返回 403,而不是 404 :person_shrugging:

我找到了问题:

正确的网址是 https://forums.mysite.uk/groups/1949/owners,去掉了 /admin/

2 个赞

您还需要告诉服务器您发送的是 json,而不是表单。

3 个赞

我刚注意到我还没有感谢大家帮我解决了问题。抱歉,非常感谢!

1 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.