首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在GitHub企业知识库中发布PR评论

如何在GitHub企业知识库中发布PR评论
EN

Stack Overflow用户
提问于 2020-05-04 14:29:57
回答 1查看 299关注 0票数 0

根据GitHub REST API的说法,要列出在GitHub拉请求上发布的评论,我们需要将网址放在一起:

代码语言:javascript
运行
复制
/repos/:owner/:repo/pulls/:pull_number/comments

在这个URL中有三个参数::owner:repo:pull_number

下面是一个curl命令行示例,该示例获取对一个拉请求的json响应:

代码语言:javascript
运行
复制
curl "https://api.github.com/repos/37signals/sub/issues/2/comments" -v

让我们打破这个网址..。

  • 这里的:owner37signals
  • :reposub
  • :pull_number2

我正在处理的拉请求是:

代码语言:javascript
运行
复制
https://github.prod.mycompany.com/MyTeamName/MyRepoName/pull/3

同样,为了将GitHub API URL地址组合在一起,我需要:owner:repo:pull_number

我试过:

代码语言:javascript
运行
复制
curl https://api.github.com/repos/mycompany/MyRepoName/issues/3/comments -v

但是它返回一个Not Found错误。

发出API请求的正确URL是什么?

EN

回答 1

Stack Overflow用户

发布于 2020-05-04 22:44:47

通过Github,我们获得了许多不同的API URL,我们都可以通过用户名/密码组合进行身份验证:

代码语言:javascript
运行
复制
curl -i https://github.mycompany.com/api/v3 -u my_git_username:@my_password

或者用Github令牌:

代码语言:javascript
运行
复制
curl -H "Authorization: token 123a42s67f38g45hh67aj89a014sd11fhh444ee1" https://github.mycompany.com/api/v3

无论您选择哪种auth方法,curl查询的输出都是相同的,它在下面被复制/粘贴:

代码语言:javascript
运行
复制
{
  "current_user_url": "https://github.mycompany.com/api/v3/user",
  "current_user_authorizations_html_url": "https://github.mycompany.com/settings/connections/applications{/client_id}",
  "authorizations_url": "https://github.mycompany.com/api/v3/authorizations",
  "code_search_url": "https://github.mycompany.com/api/v3/search/code?q={query}{&page,per_page,sort,order}",
  "commit_search_url": "https://github.mycompany.com/api/v3/search/commits?q={query}{&page,per_page,sort,order}",
  "emails_url": "https://github.mycompany.com/api/v3/user/emails",
  "emojis_url": "https://github.mycompany.com/api/v3/emojis",
  "events_url": "https://github.mycompany.com/api/v3/events",
  "feeds_url": "https://github.mycompany.com/api/v3/feeds",
  "followers_url": "https://github.mycompany.com/api/v3/user/followers",
  "following_url": "https://github.mycompany.com/api/v3/user/following{/target}",
  "gists_url": "https://github.mycompany.com/api/v3/gists{/gist_id}",
  "hub_url": "https://github.mycompany.com/api/v3/hub",
  "issue_search_url": "https://github.mycompany.com/api/v3/search/issues?q={query}{&page,per_page,sort,order}",
  "issues_url": "https://github.mycompany.com/api/v3/issues",
  "keys_url": "https://github.mycompany.com/api/v3/user/keys",
  "notifications_url": "https://github.mycompany.com/api/v3/notifications",
  "organization_repositories_url": "https://github.mycompany.com/api/v3/orgs/{org}/repos{?type,page,per_page,sort}",
  "organization_url": "https://github.mycompany.com/api/v3/orgs/{org}",
  "public_gists_url": "https://github.mycompany.com/api/v3/gists/public",
  "rate_limit_url": "https://github.mycompany.com/api/v3/rate_limit",
  "repository_url": "https://github.mycompany.com/api/v3/repos/{owner}/{repo}",
  "repository_search_url": "https://github.mycompany.com/api/v3/search/repositories?q={query}{&page,per_page,sort,order}",
  "current_user_repositories_url": "https://github.mycompany.com/api/v3/user/repos{?type,page,per_page,sort}",
  "starred_url": "https://github.mycompany.com/api/v3/user/starred{/owner}{/repo}",
  "starred_gists_url": "https://github.mycompany.com/api/v3/gists/starred",
  "team_url": "https://github.mycompany.com/api/v3/teams",
  "user_url": "https://github.mycompany.com/api/v3/users/{user}",
  "user_organizations_url": "https://github.mycompany.com/api/v3/user/orgs",
  "user_repositories_url": "https://github.mycompany.com/api/v3/users/{user}/repos{?type,page,per_page,sort}",
  "user_search_url": "https://github.mycompany.com/api/v3/search/users?q={query}{&page,per_page,sort,order}"
}
`

要查询拉请求,请向curl查询提供包含拉请求号(:number)、存储库名称(:repo)和MyTeamName (:owner)的URL:

代码语言:javascript
运行
复制
curl -u my_git_username:@my_password -H "Accept: application/vnd.github.shadow-cat-preview+json" https://github.mycompany.com/api/v3/repos/MyTeamName/MyRepoName/pulls/3

或者使用Github令牌:

代码语言:javascript
运行
复制
curl -H "Authorization: token 123a42s67f38g45hh67aj89a014sd11fhh444ee1" -H "Accept: application/vnd.github.shadow-cat-preview+json" https://github.mycompany.com/api/v3/repos/MyTeamName/MyRepoName/pulls/3
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61594636

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档