I trying to commit a file to a github repo using C# and OctoKit using the following code:
static async void CommitFile()
{
var ghClient = new GitHubClient(new ProductHeaderValue("Octokit-Test"));
ghClient.Credentials = new Credentials("//...//");
// github variables
var owner = "owner";
var repo = "repo";
var branch = "main";
// create file
var createChangeSet = await ghClient.Repository.Content.CreateFile(owner,repo, "file2.txt",new CreateFileRequest("File creation", "Hello World!", branch));
}
Whenever I execute it I get:
Octokit.NotFoundException: 'Not Found'
Here are the following things I want to mention:
- I generated a personal access token
- The repo is private
- If I put incorrect personal access token I get "Bad Credentials" error. If I put the correct credentials I get the not found error.
var gitHubClient = new GitHubClient(new ProductHeaderValue(repoName)); gitHubClient.Credentials = new Credentials(authorizedKey);