Download a repo public/private as .zip with c# #70423
Replies: 1 comment
-
Recognized when I use the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Select Topic Area
Bug
Body
Hi, we need to download repos as .zip, we have public and private ones. The public ones are worikg, as soon as we switch to a private one with a token, the http result shows always 404 "not found".
Token settings
Repo Access: All repositories
Type: Fine-grinded tokens
Permissions: Contents , Meta (both "Read-Only")`
Snippet for public repo
string owner = "owner";
string repo = "repoName";
string releaseTagName = "release";
string accessToken = string.Empty;
using (HttpClient client = new HttpClient())
{
if (!string.IsNullOrEmpty(accessToken))
{
client.DefaultRequestHeaders.Add("Authorization", $"token {accessToken}");
}
// Get the URL for the .zip file of the release
string zipUrl = $"https://github.com/{owner}/{repo}/archive/refs/tags/{releaseTagName}.zip";
// Download the .zip file
HttpResponseMessage zipResponse = await client.GetAsync(zipUrl);
}
`
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions