# Using the Discourse API ruby gem to post a topic as a specific user

**URL:** <https://meta.discourse.org/t/using-the-discourse-api-ruby-gem-to-post-a-topic-as-a-specific-user/98380>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [30.Сентябрь.2018 01:34:01 UTC](https://meta.discourse.org/t/using-the-discourse-api-ruby-gem-to-post-a-topic-as-a-specific-user/98380 "2018-09-30T01:34:01Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)\
**Post date:** [30.Сентябрь.2018 01:34:01 UTC](https://meta.discourse.org/t/using-the-discourse-api-ruby-gem-to-post-a-topic-as-a-specific-user/98380/1 "2018-09-30T01:34:01Z")

</div>

I’m trying to use the following to post a new topic as a non-staff user via the Discourse API ruby gem:

```plaintext
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__ )
require File.expand_path('../../lib/discourse_api', __FILE__ )

client = DiscourseApi::Client.new("https://www.example.com")
client.api_key = "GLOBAL_KEY"
client.api_username = "ADMIN_USERNAME"

topic = client.create_topic (
  category: "Category",
  skip_validations: true,
  auto_track: false,
  title: "This is a test topic",
  created_at: "Sat Jul 22, 2016 5:00 pm GMT-0700",
  api_username: "NORMAL_USER_USERNAME",
  raw: "This is just a test"
)

```

When I run the above, I get:

```plaintext
/Users/me/discourse_api/lib/discourse_api/client.rb:147:in `handle_error': {"status"=>404, "error"=>"Not Found"} (DiscourseApi::NotFoundError)
	from /Users/me/discourse_api/lib/discourse_api/client.rb:136:in `request'
	from /Users/me/discourse_api/lib/discourse_api/client.rb:87:in `post'
	from /Users/me/discourse_api/lib/discourse_api/api/topics.rb:12:in `create_topic'
	from test.rb:11:in `<main>'

```

There are no restrictions on the category. And I can confirm that the normal user is able to post a new topic through the actual site.

Interestingly, if I grant the normal user moderation power, everything works fine - the topic posts. This seems to imply there is a permission issue going on somewhere, but I’m having trouble tracking it down.

It also might be worth noting that I am able to post a reply to an existing topic as the normal user using `create_post()` without granting them moderation power.

Any suggestions would be greatly appreciated!

Thanks!

---

_[View the full topic](https://meta.discourse.org/t/using-the-discourse-api-ruby-gem-to-post-a-topic-as-a-specific-user/98380)._
