How to update user_id of post using api?


(Mudedla Panduranga Rao ) #1

I’m using ruby api to integrate discourse in my website. I’m successfully posting comments for a topic using api, but posted_by is showing as admin user. How can i replace it by logged in user.

Thanks


(Joe Buhlig) #2

Can you share the code you’re using to post the replies?


(Mudedla Panduranga Rao ) #3
$client = DiscourseApi::Client.new("http://disc.fabmarks.com/")
$client.api_key = "api_key"
$client.api_username = "admin_username"

post_comment = $client.create_post(
      :topic_id => params[:discourse_topic_id],
      :raw => params[:post_content]
    )

(Joe Buhlig) #4

I would assume it’s using the system user since you’re not passing a user id to the create_post method. Try adding something along these lines: :user_id => params[:user_id]