Getting 403 for Unlike a post by the user

I am trying to hit the unlike API on discourse with HTTP, Node.js. I am sending the particular payload :

      host: discourseHost,
      port: discoursePort,
      path: '/post_actions/' + parseInt(req.params.post_id),
      method: 'DELETE',
      headers: {
        'Content-Type': 'application/json',
        'Content-Length': Buffer.byteLength(data),
        'Api-Key': DISCOURSE_API_KEY,
        'Api-Username': userData.discourse_username,
        'Accept': 'application/json'
      }

But I am getting this as response :

STATUS: 403
BODY: {“errors”:[“You are not permitted to view the requested resource.”]}

Can anyone suggest me what I need to change in my payload/request.

I tried to hit the discourse API /post_actions/{id} directly from postman, with the following headers :

Content-Type:application/x-www-form-urlencoded
Api-Key:blah blah
Api-Username:eluser2019522
Accept:application/json

Still I am getting the response as :

{
    "errors": [
        "You are not permitted to view the requested resource."
    ]
} 

I am stuck here. Any help will be fine.

You can cancel a like heart :heart: only within a limited time span.

Maybe you are trying to unlike a too old like.

3 Likes

Oh yeah, Thanks a lot. That was the reason. @jesus2099 .

1 Like

From where I can change this? Can i change this from the admin portal by any chance?

You can change it in the post undo action window mins site setting located here: http://forum.example.com/admin/site_settings/category/all_results?filter=post%20undo%20action%20window%20mins. By default, it should be 10 minutes.

4 Likes