1

I'm working with PyGithub to get basic access to my own github repo. Most methods require a "path" and I'm not sure what that is. What parameters would I use in the .get_contents() function? Simple example:

    from github import Github
    g = Github("***","***")
    repo = g.get_user().get_repo("my_projects")
    contents = repo.get_contents()
maddyloo
  • 11
  • 2
  • what is the response you are getting for the above snippet? – Srikanth Bhandary Oct 03 '15 at 03:37
  • traceback error; last 2 lines read: File "/Library/Python/2.7/site-packages/PyGithub-1.25.2-py2.7.egg/github/Requester.py", line 177, in __check raise self.__createException(status, responseHeaders, output) github.GithubException.UnknownObjectException: 404 {u'documentation_url': u'https://developer.github.com/v3', u'message': u'Not Found'} – maddyloo Oct 03 '15 at 03:38
  • according to pygithhub above exception gets generated for below reason: Exception raised when a non-existing object is requested (when Github API replies with a 404 HTML status) – Srikanth Bhandary Oct 03 '15 at 03:41
  • the repo objects exists (i can call repo.name and get "my_projects" with no error). I need to figure out what to put in get_contents( ) I think – maddyloo Oct 03 '15 at 03:44
  • you can refer at https://github.com/PyGithub/PyGithub/issues/168 – Srikanth Bhandary Oct 03 '15 at 03:46
  • Check the scope of your user credentials. https://developer.github.com/v3/oauth/#scopes – Srikanth Bhandary Oct 03 '15 at 03:47

1 Answers1

0

You need to pass the following arguments:

path - string - The content path.

ref - string - The name of the commit/branch/tag. Default: the repository’s default branch (usually master)

E.g - repo.get_contents('config/version.rb','development')

See more here

user2503775
  • 4,267
  • 1
  • 23
  • 41