How to search using GitHub API in private organizations

霸气de小男生 提交于 2019-12-11 02:20:07

问题


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.

回答1:


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



来源:https://stackoverflow.com/questions/22388228/how-to-search-using-github-api-in-private-organizations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!