Mattermost, Inc.

Can not add reaction with API

Hello,

The post is initially created using bot. I am trying to add reactions to the post with API, however, I got a 403 error saying I can not save reaction for another user.

How can I add reactions with API?

Hello, @ilyakonovalenko

Specifically under Create a reaction section, can I please confirm how did you run the API on your end and can you also the sample command here (you can remove the user_id and post_id) so we can check if it is structured properly?

Is your personal access token has the right permission based on the documentation here?

Also, were you able to add a reaction to the post directly on the desktop / web browser app?

Hello,

I am using the following:

  • URL: /api/v4/reactions
  • Method: POST
  • JSON: {“user_id”:MY_ID,“post_id”:POST_ID,“emoji_name”:":email:",“created_at”:1590137025.2786}

I am not sure about created_at field, I used microtime() PHP function to generate it. I also tried 0, as described in the API.

The error I am geting is: api.reaction.save_reaction.user_id.app_error

Hello, @ilyakonovalenko

I have tested this on my end and can confirm that the following command works on my end, even without the created_at parameter:

curl --location --request POST "<url>/api/v4/reactions" --header "Authorization: Bearer <personal_token>" --header "Content-Type: application/json" --header "X-Requested-With: XMLHttpRequest" --data "{\"user_id\":\"<your_user_id>\", \"post_id\":\"<post_id>\", \"emoji_name\":\"email"\"}

Replace the with the FQDN of your instance, <personal_token> with your personal token generated, and <post_id> with the post ID that you are adding the reaction to.

Let me know how it goes on your end. Thanks.