以前是可以的,但最近在使用 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 : /)