Cannot load gitub release using API

I have a github version without any resources:

$ curl https://api.github.com/repos/cljsinfo/api-docs/releases/1260660/assets [ ] 

But I can not load the resource in this version:

 $ curl -X POST --header "Content-Type:application/edn" --data-binary @cljsdocs-full.edn "https://api.github.com/repos/cljsinfo/api-docs/releases/1260660/assets?name=full.edn&access_token=$(cat my-token)" { "message": "Not Found", "documentation_url": "https://developer.github.com/v3" } 

My api access token has public_repo access. Thanks for any help downloading this asset.

+6
source share
3 answers

The resource download URL has the form https://<upload_url>/repos/:owner/:repo/releases/:id/assets?name=foo.zip . There are several possible reasons why you might get a very useless "Not Found" error:

  • The identifier of the wrong version . The :id field in the above URL is NOT the name you gave to the release, but the numeric identifier generated by GitHub (possibly the database identifier). To get the release identifier, you must call the release API and search for the JSON response for the release, where tag_name is the name you used. For example, if you named your release v0.0.3 , do a JSON search for the release with "tag_name": "v0.0.3" and use this id release.
  • Invalid download URL . The URL you use to download assets is not the same as for all other API calls. To get the correct download URL, you use the same API releases , find your version using tag_name a, described above, and extract the upload_url field from the JSON response. This is Ivan's answer (accepted).
  • There are no permissions to access GitHub tokens . This is the one that knocked me off the worst, as the token I used was able to make release APIs API calls and get information about my repo, but DO NOT load assets into the same repo. The "Not Found" error response does not indicate this at all. Check the permissions for your token on the personal access tokens page and make sure that repo and / or public_repo .
+4
source

Note that for GitHub configured for Enterprise, the download URL is not the same as for 'github.com', and you should use the 'upload_url' returned when creating / requesting the release: Get release API documents

For example, here is what returned from our github server of our enterprise (it is slightly soaked to protect the culprits):
"upload_url": "https://git.example.com/api/uploads/repos/example-owner/example-repo/releases/5/assets{?name,label}",

+1
source

Source: https://habr.com/ru/post/986618/


All Articles