Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

github API unsupported media type 415

I was using github API in Meteor but could not solved this issue:

This code tries to get the total number of traffic for a certain repo.

HTTP.call( 'GET', 'https://api.github.com/repos/hackmdio/hackmd/traffic/views', 
    {
        headers: 
        {
            'Content-Type':'application/json',
            "Accept":"application/vnd.github.v3+json",
            "User-Agent": "whales"
        },
    },
    function( error, response ) {
  if ( error ) {
    console.log('---------------------------error occurred-----------------------------------')
    console.log('---------------------------error occurred-----------------------------------')

    console.log( error );
  } else {

    console.log('--------------------------data got it!!-------------------------------------')
    console.log('--------------------------data got it!!-------------------------------------')

    console.log(response);
  }
});

Error:

{
  "message": "If you would like to help us test the Repo Traffic API during its preview period, you must specify a custom media type in the 'Accept' header. Please see the docs for full details.",
  "documentation_url": "https://developer.github.com/v3"
}

I searched for similar issues and added "Content-Type" and "Accept" but it's still not working.

I then tried doing this in Postman and also in terminal with the same headers but this error kept happening. enter image description here

Thanks a lot.

like image 881
whales Avatar asked Nov 02 '25 18:11

whales


1 Answers

You will need to add an Accept: application/vnd.github.spiderman-preview header to your request in order to access the Repo Traffic API whilst it is in preview form. From the API docs:

APIs for repository traffic are currently available for developers to preview. During the preview period, the APIs may change without advance notice. Please see the blog post for full details.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.spiderman-preview

like image 104
kfb Avatar answered Nov 05 '25 14:11

kfb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!