When creating a repository using the following method
repos, _, err := client.Repositories.Create(ctx, "", repo)
It throws the following error
POST https://api.github.com/user/repos: 404 Not Found
The client was created using the following method
ctx := context.Background()
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: <token returned from github after oauth>},
)
tc := oauth2.NewClient(ctx, ts)
client := github.NewClient(tc)
404 is a strange response.
https://developer.github.com/v3/repos/#create are the GutHub API docs for that endpoint.
Do you have the right OAuth scopes? Did you provide the required Repository.Name field?
This is the repository var which i user
repo := &github.Repository{
Name: github.String(RepoName),
Private: github.Bool(false),
}
I am able to successfully list the repositories of the same user, using the same client by the following method.
repos, _, err := client.Repositories.List(ctx, "", nil)
But i'm getting the above mentioned error when trying the create a repo.
@shurcooL the problem was with OAuth scopes. I don't know how i missed it.Thank you so much.
Most helpful comment
@shurcooL the problem was with OAuth scopes. I don't know how i missed it.Thank you so much.