CodePudding user response:
I decided to answer my own question because it took me several hours to realize the solution to this and I couldn't find it anywhere online.
Basically, the reason this happens is purely due to the way the path is written.
If you remove the /
from before the word 'repos' then the command works perfectly well both on PowerShell, wsl and git-bash terminals.
So the correct script should be:
# GitHub CLI api
# https://cli.github.com/manual/gh_api
gh api \
-H "Accept: application/vnd.github json" \
repos/OWNER/REPO/pulls/PULL_NUMBER
Again, this is different than what is officially written in the GitHub API documentation because I removed the /
before the word 'repos'.
I hope this helps others as well.
CodePudding user response:
While the gh code sample in the REST API does have an extra /
prefix, the actual gh api man page does not:
Examples:
# list releases in the current repository
$ gh api repos/{owner}/{repo}/releases
# post an issue comment
$ gh api repos/{owner}/{repo}/issues/123/comments -f body='Hi from CLI'
Placeholder values "
{owner}
", "{repo}
", and "{branch}
" in the endpoint argument will get replaced with values from the repository of the current directory or the repository specified in theGH_REPO
environment variable.Note that in some shells, for example PowerShell, you may need to enclose any value that contains "
{...}
" in quotes to prevent the shell from applying special meaning to curly braces.