简体   繁体   中英

Why i am getting a not found error when i try to create a new file with octokitnet?

i am trying to do an application that upload a json file to my github this file is going to be used to know what have done the user in the application.

But i am stuck with the creation of the file, i have this function

public async void CrearCredenciales(string nombre, string clave)
        {
            cliente = new GitHubClient(new ProductHeaderValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName));
            credenciales = new Credentials("token");
            var user = await this.cliente.User.Get("davidgmd");          
            var repositorio = cliente.Repository.Get("davidgmd", "Proyecto-de-fin-de-grado");

            // create file
            var createChangeSet = await cliente.Repository.Content.CreateFile(
                                            user.Login,
                                            "Proyecto-de-fin-de-grado",
                                            nombre + ".json",
                                            new CreateFileRequest("File creation",
                                                                  "Hello World!",
                                                                  "master"));

            var request = new SearchCodeRequest("Clave")
            {
                FileName = nombre + ".json"
            };
            var result = await this.cliente.Search.SearchCode(request);
            var cadena = user.Bio.ToString();
        }

when the application try to execute "createChangeSet" i get an exception "Octokit.NotFoundException: 'Not Found'"

when i press to get more details, says "Api:Error Message not found".

I have revised the token, the user is correct, the name of the repo is right too, the settings for the token are: enter image description here

And for user all marked user Update all user data read:user Read all user profile data user:email Access user email addresses (read-only) user:follow Follow and unfollow users

Finally i get what was wrong, i was creating a credential, but that credential hadn't been asigned to the client.

So for the application that client was anonymous and ofc couldn't create a file.

now i am going to try to put as message the json itself, but i suppose this question is finish.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM