无法通过 DiscourseApi 发送PM - "errors"=>["You must select a valid user."]

以前是可以的,但最近在使用 DiscourseApi 发送私信时,我一直收到:DiscourseApi::UnprocessableEntity ({"action"=>"create_post", "errors"=>["You must select a valid user."]}),但用户是有效的(无论我尝试哪个用户名都会发生同样的情况)。

通过 Discourse gem 的控制台:

user = "MyUserName"
client = DiscourseApi::Client.new("https://myforum.com")
client.api_key = "h03873hxjd734i4hdjdudje94udjdjdeje83483483jdjdjdjed84u34e"
client.api_username = "ForumUserName"

client.create_private_message(
  title: "testing a title",
  raw: "Hey this is a test",
  target_usernames: user
)

看起来是个 bug?(感觉之前标签也出现过类似的 bug : /)

1 个赞

嗨 Aston,

看起来 target_usernames 已被弃用。

请尝试使用 target_recipients:slight_smile:

5 个赞

请注意,您还需要使用 create_pm(而不是 create_private_message)。

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