Reputation: 151
I am new to Octokit.NET. Trying to use it to login to my repo and then get a particular repository in a WinRT 8.1 Universal app. Ultimately I want to read some .cs files in that repo as text. I am using following code to authenticate and get all repos. However I keep empty error message. Not sure if I am using the Octokit the right way-
var credentials = GithubHelper.Credentials;
var connection = new Octokit.Connection(new Octokit.ProductHeaderValue("dotnet-test-functional"),new Uri("https://mygit.github.com"))
{
Credentials = credentials
};
var octokitClient = new Octokit.GitHubClient(connection);
IReadOnlyList <Octokit.Repository> repos = await octokitClient.Repository.GetAllForCurrent();
I would appreciate if someone can help me out with this.
Thanks
Upvotes: 1
Views: 1483
Reputation: 583
Just for googlers, the octokit.net api now has Repository Contents APIs in it.
var AllContent = await client.Repository.Content.GetAllContent(repo.Owner.Login, repo.Name);
To get unencoded text from a file, you can do this
var textOfFirstFile = AllContent[0].Content;
Upvotes: 2
Reputation: 2718
Not sure about the specific exception here, but I'll walk you through the steps anyway.
The baseAddress
overload on GitHubClient
is for when you need to connect to a GitHub Enterprise environment. If you're just connecting to github.com, you don't need to specify it.
var client = new GitHubClient(new ProductHeaderValue("dotnet-test-functional"));
client.Credentials = GithubHelper.Credentials;
var repos = await client.Repository.GetAllForCurrent();
That should return you the repositories associated with the current user.
However the Repository Contents APIs are not currently implemented (there's a pull request in the queue where we've been discussing how to go about it, but it's not close to ready).
Upvotes: 0