# Issues with creating a post and locking the topic via the API

**URL:** <https://meta.discourse.org/t/issues-with-creating-a-post-and-locking-the-topic-via-the-api/159003>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [July 28, 2020, 2:55am UTC](https://meta.discourse.org/t/issues-with-creating-a-post-and-locking-the-topic-via-the-api/159003 "2020-07-28T02:55:38Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![AstonJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/astonj/32/215041_2.png) [@AstonJ](https://meta.discourse.org/u/AstonJ)\
**Post date:** [July 31, 2020, 1:11am UTC](https://meta.discourse.org/t/issues-with-creating-a-post-and-locking-the-topic-via-the-api/159003/5 "2020-07-31T01:11:25Z")

</div>

> [@blake](#):
>
> I looked into this for a bit today just to see if it would be a quick change, but many of the actions that you can apply to topics are best performed after the topic exists.

Hi Blake, the topic I was trying it for already exists 🙂

This was my process:

```ruby
  bot.create_post(topic_id, post_content)
  bot.switch_to_master_bot!("system")
  bot.lock_topic("", topic_id)

  def create_post(topic_id, post_content)
    @client.create_post(
      topic_id: "#{topic_id}",
      raw: "#{post_content}",
    )
  end

  def lock_topic(slug, topic_id)
    params = { status: 'closed', enabled: true }
    @client.change_topic_status(slug, topic_id, params)
  end

```

I’m using the Discourse API Gem.

Are you saying the above should work (or is working for you)?

---

_[View the full topic](https://meta.discourse.org/t/issues-with-creating-a-post-and-locking-the-topic-via-the-api/159003)._
