如何在私人组织中使用GitHub API进行搜索 [英] How to search using GitHub API in private organizations

查看:291
本文介绍了如何在私人组织中使用GitHub API进行搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个私人组织GitHub(企业)存储库,例如 github.mycompany.com



我想使用GitHub API在代码中搜索字符串。如何搜索 mycompany -specific GitHub存储库?



我试过下面的查询并收到404: p>

curl -i -H授权:令牌<令牌> https://github.mycompany.com/api/v3/search/code?q=class



它似乎因为我尝试了 curl -u< userName>




  • 如果我输入了错误的密码,我会收到验证错误。


  • 如果我给出正确的密码,它会经过,但会为搜索查询返回404。 h2_lin>解决方案

目前,GitHub Enterprise上的Search API仍处于预览状态。因此,您需要在Accept标头中指定特殊的媒体类型才能使用。



请试试看:



curl -i -HAccept:application / vnd.github.preview + json-HAuthorization:token< token> https://github.mycompany.com/api/v3/search/code?q=class


I have a private organization GitHub (enterprise) repository, e.g. github.mycompany.com.

I want to search strings in code using the GitHub API. How do I search in mycompany-specific GitHub repositories?

I tried the query below and received 404:

curl -i -H "Authorization: token <token>" https://github.mycompany.com/api/v3/search/code?q=class

It seems to be authenticating fine, since I tried curl -u <userName> and

  • If I give the wrong password, I get an authentication error.
  • If I give the right password, it goes through, but returns 404 for the search query.

解决方案

Currently, the Search API is still in preview on GitHub Enterprise. As a result, you need to specify a special media type in the Accept header to get things working.

Give this a try:

curl -i -H "Accept: application/vnd.github.preview+json" -H "Authorization: token <token>" https://github.mycompany.com/api/v3/search/code?q=class

这篇关于如何在私人组织中使用GitHub API进行搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆