Seeing errors when calling List Responses on PullRequest Comment

Hello,

I am attempting to Reactions on a PullRequest Comment and I’m seeing this “Resource not accessible by integration” error. I’ve seen that people get that error when trying to write when they only have read access. I would think this API only needs read access though.

I believe I’m using GITHUB_TOKEN as my token so I’m a bit confused. Is it possible that this API is setup to need write access? Did I miss something?

My action.yml looks like this:

author: Myyk
description: Tally votes on PR
inputs:
  token:
    description: 'GITHUB_TOKEN or a repo scoped PAT.'
    default: ${{ github.token }}
  repository:
    description: 'The full name of the repository in which to tally votes.'
  comment-id:
    description: Comment id of comment containing votes.
    required: true
outputs:
  for:
    description: The number for the change.
  against:
    description: The number against the change.
runs:
  using: node12
  main: index.js

In another action in the same workflow, I’m successfully modifying a PR comment, so I seem to have write access on my token. I’m pretty confused what’s going on here.

I’m creating my octokit like this in my js code following https://github.com/actions/toolkit/tree/main/packages/github since that API needs the preview parameter:

    const octokit = github.getOctokit(
      inputs.token,
      {
        previews: ['squirrel-girl'],
      },
    );

Calling the API with something like this:

      octokit.reactions.listForPullRequestReviewComment({
        owner: owner,
        repo: repo,
        comment_id: commentId,
        content: reaction,
      });

I’m not sure if the curl works on the endpoint even. Trying to follow the docs here https://docs.github.com/en/rest/reference/reactions#list-reactions-for-an-issue.

curl  \
  -H "Accept: application/vnd.github.squirrel-girl-preview+json" \
  https://api.github.com/repos/myyk/git-democracy/pulls/comments/677573350/reactions

Seeing:

  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/reference/reactions#list-reactions-for-a-pull-request-review-comment"
}

Am I using the incorrect? I’m not sure what I’m missing.

Hi @myyk,

Glad to see you in Github Community Forum!

The API url should be “/repos/{owner}/{repo}/issues/comments/{comment_id}/reactions”, in your curl command, it’s ‘pulls’ which is not correct.

In your action index.js line 13, please add issues as well, should be:

await octokit.request('GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions', {

Thanks

1 Like

Hi @weide-zhou ,

Thank you for your response! Sorry for the confusing link above, the docs should be at https://docs.github.com/en/rest/reference/reactions#list-reactions-for-a-pull-request-review-comment since I am in trying to list reactions on a pull request comment (not on an issue’s comment as the link was).

I must be using the API incorrectly. I think if we solve why the curl request is failing it might become obvious what’s wrong in code.

curl -H "Accept: application/vnd.github.squirrel-girl-preview+json" https://api.github.com/repos/myyk/git-democracy/pulls/comments/677573350/reactions

This returns "Not Found" when I think it should be pulling data from https://github.com/myyk/git-democracy/pull/10#issuecomment-677573350.

Do you see anything wrong here?

Hi @myyk,

Thanks for your quick reply!

pull request is actually an issue.

The comment on your pull request is not a review comment, you can confirm with rest api here.

Hence, you should use the api below for comment reaction:
https://docs.github.com/en/rest/reference/reactions#list-reactions-for-an-issue-comment

GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions
1 Like

Hi @weide-zhou,

Oh yeah, those are do use that different API, thanks for helping me understand that github nomenclature.

I have a small follow up question that. In the API docs, I see this:

The `reactions` key will have the following payload where url can be used to construct the API location for listing and creating reactions.

{
  "total_count": 5,
  "+1": 3,
  "-1": 1,
  "laugh": 0,
  "confused": 0,
  "heart": 1,
  "hooray": 0,
  "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/reactions"
}

But in my request, I don’t a reactions section as described. Is there something I’m not passing in the call or about the way it’s called that’s not returning it?

curl  \
 -H "Accept: application/vnd.github.squirrel-girl-preview+json"   \
  https://api.github.com/repos/myyk/git-democracy/issues/comments/677573350/reactions

Hi @myyk,

As the API doc mentioned, this reaction object exists in issue coment payload, you can get it via list the issue comment with media type: application/vnd.github.squirrel-girl-preview.


Thanks

1 Like

Thank you @weide-zhou! I was able to make a request exactly as I wanted to. Thank you for your help!

To summarize what you showed me in regard to getting reaction summary info from https://github.com/myyk/git-democracy/pull/10#issuecomment-677573350:

  1. I was using the wrong API since the comment uses the issue comments API, not the pull request comments API even though it appears on the Pull Request page. https://developer.github.com/v3/issues/comments/#get-an-issue-comment

  2. I needed to add the Accept: application/vnd.github.squirrel-girl-preview header.

I ended up with something like this:

const octokit = github.getOctokit(
  inputs.token,
  {
    previews: ['squirrel-girl'],
  },
);

octokit.issues.getComment({
  owner: owner,
  repo: repo,
  comment_id: commentId,
});
1 Like