سؤال

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top