Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Octokit.NotFoundException #2969

Closed
1 task done
ghost opened this issue Sep 26, 2024 · 5 comments
Closed
1 task done

[BUG]: Octokit.NotFoundException #2969

ghost opened this issue Sep 26, 2024 · 5 comments
Labels
Type: Bug Something isn't working as documented

Comments

@ghost
Copy link

ghost commented Sep 26, 2024

What happened?

I try octokit for the first time using nuget package 13.0.1

This is my code

async public Task UpdateGithub()
{
var ghClient = new GitHubClient(new ProductHeaderValue("Octokit"));
ghClient.Credentials = new Credentials("login", "password");

// github variables
var owner = "owner";
var repo = "repo.github.io";
var branch = "main";

var targetFile = "test.txt";

try
{
    // try to get the file (and with the file the last commit sha)
    var existingFile = await ghClient.Repository.Content.GetAllContentsByRef(owner, repo, targetFile, branch);

    // update the file
    var updateChangeSet = await ghClient.Repository.Content.UpdateFile(owner, repo, targetFile, new UpdateFileRequest("API File update", "Hello Universe! " + DateTime.UtcNow, existingFile.First().Sha, branch));
}
catch (Octokit.NotFoundException)
{
    // if file is not found, create it
    var createChangeSet = await ghClient.Repository.Content.CreateFile(owner, repo, targetFile, new CreateFileRequest("API File creation", "Hello Universe! " + DateTime.UtcNow, branch));
}

}

I get 2 times a Octokit.NotFoundException.
Can somebody tell me what's wrong and why?

I replaced "login", "password", "owner", "repo.github.io" and "main" by the correct value for my github repo.

Jessica

Versions

Octokit nuget 13.0.1

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ghost ghost added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Sep 26, 2024
@kfcampbell kfcampbell moved this from 🆕 Triage to 🏗 In progress in 🧰 Octokit Active Sep 27, 2024
@kfcampbell kfcampbell removed the Status: Triage This is being looked at and prioritized label Sep 27, 2024
@kfcampbell
Copy link
Member

Are you actually using your GitHub password to authenticate? We removed support for that as of August 2021 IIRC. If so, you'll need to generate a Personal Access Token and use that to authenticate instead.

@ghost
Copy link
Author

ghost commented Sep 27, 2024

Are you actually using your GitHub password to authenticate? We removed support for that as of August 2021 IIRC. If so, you'll need to generate a Personal Access Token and use that to authenticate instead.

Yes

Can you tell me how to generate that token and what code I need.
Is it possible to give me the code lines I need to replace the ones below?

var ghClient = new GitHubClient(new ProductHeaderValue("Octokit")); ghClient.Credentials = new Credentials("login", "password");

@ebisarlak

This comment has been minimized.

@ghost
Copy link
Author

ghost commented Oct 9, 2024

Are you actually using your GitHub password to authenticate? We removed support for that as of August 2021 IIRC. If so, you'll need to generate a Personal Access Token and use that to authenticate instead.

can you please answer how to do this?

@kfcampbell
Copy link
Member

The account that asked has been deleted, but for future reference, the docs they were looking for are here.

@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in 🧰 Octokit Active Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented
Projects
Archived in project
Development

No branches or pull requests

2 participants