2

For the past couple hours I've been trying to update a GitHub Gist via their API to no avail. I can easily POST to https://api.github.com/gists and create a new Gist, but I can't ever get a PATCH to https://api.github.com/gists/:id to work. How do I update Gists via their API? Am I missing some important detail?

Here's a JSFiddle of my present predicament: http://jsfiddle.net/ZzUsv/4/

The code itself:

var Gist = Backbone.Model.extend({
    urlRoot: 'https://api.github.com/gists',
    defaults: {
        description: 'A terse gist',
        'public': true,
        files: {
            'html.html': {
                content: 'test'
            },
            'css.css': {
                content: 'test'
            },
            'js.js': {
                content: 'test'
            }
        }
    }
});

var my_gist = new Gist;
my_gist.save( my_gist.toJSON(), {
    success: function(){
        $('body').append('successfully created gist');
        my_gist.save({ description: '<div>A less terse gist</div>' }, {
            patch: true,
            success: function(){
                $('body').append('<div>successfully updated gist</div>');
            },
            error: function( model, xhr, options ){
                $('body').append('<div><b>error updating gist</b></div>');
                $('body').append( JSON.stringify( xhr ) );
            }
        });
    }
});

Relevant documentation: http://developer.github.com/v3/gists/#edit-a-gist

1
  • Do you use SSL? Coz github uses it and u can not use JSON via different protocols. Commented Feb 27, 2013 at 9:13

1 Answer 1

6

Looks like this is a simple case of poor documentation. It seems you're not able to edit or delete anonymous Gists, despite having the ID provided to you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.