Skip to content Skip to sidebar Skip to footer

Post To Github V3 Api Using Ajax And Javascript Fails With A Http 404

I am trying to post a blob to the GitHub API in JavaScript / jQuery as per the docs https://developer.github.com/v3/git/blobs/#create-a-blob - however I keep receiving a 404 reque

Solution 1:

You can't use JSONP to make non-GET requests.

However, the good news is that you don't need to use JSONP since the API supports CORS.

Give this a try:

var uploadURL ="https://api.github.com/repos/daniellevass/web-quiz/git/blobs" + accessToken;

console.log(uploadURL);

$.ajax({
  type: "POST",
  url: uploadURL,
  contentType: "application/json",
  dataType: "json",
  data: JSON.stringify({
      "content": "aGVsbG8=",
      "encoding": "utf-8"
    })
})
  .done(function( data ) {
    console.log( data );
  });

Post a Comment for "Post To Github V3 Api Using Ajax And Javascript Fails With A Http 404"