1
我想從其他網站更新我的Gist,在那裏我使用我的要點標記登錄。我無法讓它工作。我設法通過GET得到了一個要點,但用PATCH更新要點不起作用。如何更新Gist?
我不認爲這是認證的問題,因爲當獲得一個要點時,我的用戶名和個人資料顯示正確。
的JavaScript(JQuery的):
$.ajax({
url: 'https://api.github.com/gists/e3e0b182c09bf333593c',
type: 'PATCH',
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization","token f32e-----MY-TOKEN-(GIST-ACCESS)-----6f44");
}, data: {
"description":"Edit gist",
"files":{
"annexation.json":{
"content":"{\"updated content\":\"from Ajax\"}"
}
}
}
}).done(function(response) {
$('#write').text(JSON.stringify(response));
});
我不斷收到錯誤400(錯誤請求)。
響應:
{
"message": "Problems parsing JSON",
"documentation_url": "https://developer.github.com/v3/gists/#edit-a-gist"
}
能有人指出,如果我做錯了什麼?非常感謝。