I'm trying to create a public gist via javascript. I'm not using any authentication - this is all client-side.
var gist = {
"description": "test",
"public": true,
"files": {
"test.txt": {
"content": "contents"
}
}
};
$.post('https://api.github.com/gists', gist, function(data) {
});
The above code throws a 400: Bad Request - Problems parsing JSON. However, my JSON is valid. Any ideas?
Aha - I can't pass an object to $.post. It needs to be stringified first:
var gist = {
"description": "test",
"public": true,
"files": {
"test.txt": {
"content": "contents"
}
}
};
$.post('https://api.github.com/gists', JSON.stringify(gist), function(data) {});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With