Search code examples
apigithubgist

Update a gist through its API


I'm trying to edit an existing Gist through an API call, following the API docs, I'm doing a curl call like this:

curl -X PATCH -d'{"description": "the description for this gist", "files": {"file1.txt": {"content": "updated file contents"}}}' https://api.github.com/gists/5790365

But it keeps returning a 'Not Found' error.

Am I missing something here?


Solution

  • Just figured out why it wasn't working.

    It looks like you can't edit an anonymous gist, and in order to use it authenticated, you need to generate a token API for your account and specify that you want to use with gist in the scope, as shown here: https://help.github.com/articles/creating-an-oauth-token-for-command-line-use

    After that you can make API calls passing the Authorization header with the token and everything should work as expected.