# How to update user\_id of post using api?

**URL:** <https://meta.discourse.org/t/how-to-update-user-id-of-post-using-api/57413>\
**Category:** Development\
**Created:** [2017年二月15日 10:04 UTC](https://meta.discourse.org/t/how-to-update-user-id-of-post-using-api/57413 "2017-02-15T10:04:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrrao](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@mrrao](https://meta.discourse.org/u/mrrao)\
**Post date:** [2017年二月15日 10:04 UTC](https://meta.discourse.org/t/how-to-update-user-id-of-post-using-api/57413/1 "2017-02-15T10:04:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)\
**Post date:** [2017年二月16日 02:14 UTC](https://meta.discourse.org/t/how-to-update-user-id-of-post-using-api/57413/2 "2017-02-16T02:14:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mrrao](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@mrrao](https://meta.discourse.org/u/mrrao)\
**Post date:** [2017年二月16日 09:08 UTC](https://meta.discourse.org/t/how-to-update-user-id-of-post-using-api/57413/3 "2017-02-16T09:08:00Z")

</div>

```
$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]
    )

```

---

<div class="post-metadata">

**Author:** ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)\
**Post date:** [2017年二月16日 11:20 UTC](https://meta.discourse.org/t/how-to-update-user-id-of-post-using-api/57413/4 "2017-02-16T11:20:54Z")

</div>

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]`
