# How can I allow users to like posts using RESTapi

**URL:** <https://meta.discourse.org/t/how-can-i-allow-users-to-like-posts-using-restapi/339773>\
**Category:** Product Support\
**Tags:** rest-api\
**Created:** [December 2, 2024, 10:08am UTC](https://meta.discourse.org/t/how-can-i-allow-users-to-like-posts-using-restapi/339773 "2024-12-02T10:08:02Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Maduka\_Dilshan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maduka_dilshan/32/469573_2.png) [@Maduka\_Dilshan](https://meta.discourse.org/u/Maduka_Dilshan)\
**Post date:** [December 2, 2024, 10:08am UTC](https://meta.discourse.org/t/how-can-i-allow-users-to-like-posts-using-restapi/339773/1 "2024-12-02T10:08:02Z")

</div>

Hi all. I am pretty new to Discourse and checked **All Site Settings** (`/admin/site_settings`) section to find a matching option to allow any level of user to like posts using RESTapi

At the moment, all users can ( without public ) create topics, add replies etc. However a normal user (tl0, tl1 etc) cannot like to any post through the API ( But can like using the web panel )

Here’s is my category settings,

 ![image](https://global.discourse-cdn.com/meta/original/4X/7/9/1/79132a56f9c52680e5dc17b6657eb5f3663180fd.png)

I’m using following code to add a like through [API](https://docs.discourse.org/#tag/Posts/operation/performPostAction)

```plaintext
  public async likeOrThrow(contentId: number, username: string) {
    try {
      this.overrideUsername(username);
      const res = await this.client.post(`post_actions.json`, {
        id: contentId,
        post_action_type_id: 2,
        flag_topic: false,
      });
      return res.data;
    } catch (error) {
      throw this.getException(error);
    } finally {
      this.resetUsername();
    }
  }

```

It throws,

```plaintext
You are not permitted to view the requested resource.

```

However if i log into the discourse as the user then that user can make a like,

So far I have integrated, Topic create, Post Create & Bookmark APIs with same API key with same categories and username and they work without any permission issue.

Could you please help me to figure out what im doing wrong here ? Let me know if more information is needed.

Thanks

---

_[View the full topic](https://meta.discourse.org/t/how-can-i-allow-users-to-like-posts-using-restapi/339773)._
