Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update a gist through its API

Tags:

github

gist

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?

like image 313
Thiago Pontes Avatar asked Jun 16 '13 01:06

Thiago Pontes


People also ask

Can you update a gist?

You can add a new gist, modify, and delete files and code entirely from within your browser.

What is Gist API?

The Gists API enables the authorized user to list, create, update and delete the public gists on GitHub. Gists. List gists for the authenticated user. Create a gist. List public gists.

Do gists support markdown?

Most of you probably know and use Github Gists for sharing Code snippets. But did you know that Gists also support Markdown? Using Markdown makes it easy to create much richer code shareable code and even allows for an easy way to create self-contained Web content.


1 Answers

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.

like image 128
Thiago Pontes Avatar answered Sep 28 '22 07:09

Thiago Pontes