I am trying to download a zip file from a github URL from a private repo by passing an authentication token using a curl command as follows:
curl -H 'Authorization: token <PERSONAL ACCESS TOKEN HERE>’ -H 'Accept: application/vnd.github.v3.raw' -J -L -O https://api.github.com/repos/<owner>/<repo-name>/contents/abc.zip
This command downloads the zip file abc.zip properly and can be unzipped and it has all expected files
But same command when executed from the golang code, it downloads a file in json format with error:
{ "message": "Not Found", "documentation_url": "https://docs.github.com/rest/reference/repos#get-repository-content" }
Golang code snippet:
Cmd := exec.Command("curl", "-H", "'Authorization: token <Token>'", "-H", "'Accept: application/vnd.github.v3.raw'", "-O", "-L", "https://api.github.com/repos/<owner>/<repo-name>/contents/abc.zip")
Cmd.Start()
I expected the zip file to be downloaded, but it downloaded a file of type JSON data with message "Not Found".
What could I be doing wrong here?