java api to get a file content for enterprise github

github, github-api, jcabi

Solution

Finally figure out by reading source code..

    GitHubClient client = new GitHubClient(YOURENTERPRICEURL);
    client.setOAuth2Token(token);

    // first use token service
    RepositoryService repoService = new RepositoryService(client);

    try {
        Repository repo = repoService.getRepository(USER, REPONAME);

        // now contents service
        ContentsService contentService = new ContentsService(client);
        List<RepositoryContents> test = contentService.getContents(repo, YOURFILENAME);

        List<RepositoryContents> contentList = contentService.getContents(repo);
        for(RepositoryContents content : test){
            String fileConent = content.getContent();
            String valueDecoded= new String(Base64.decodeBase64(fileConent.getBytes() ));
            System.out.println(valueDecoded);
        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Problem

I tried so hard for a simple line of code that read a file content from enterprise github with oauth token, but could not find a example of such. I tried https://github.com/jcabi/jcabi-github, but it does not support enterprise github?(maybe I am wrong) Now i am trying egit: ``` GitHubClient client = new GitHubClient("enterprise url"); GitHubRequest request = new GitHubRequest(); request.setUri("/readme"); GitHubResponse response = client.get(request); ``` Then what? I only saw a getBody, maybe I need to parse it with some kinda json library? It has to be simpler..I am expecting something like: repo.get(url).getContent()

Original source