2016-09-05 1 views
1

I Github API in Meteor wurde mit, konnte aber dieses Problem nicht gelöst:Github API nicht unterstützten Medientyp 415

Dieser Code versucht, die Gesamtzahl der Verkehr für eine bestimmte Repo zu bekommen.

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); 
    } 
}); 

Fehler:

{ 
    "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" 
} 

ich für ähnliche Probleme gesucht und fügte hinzu: "Content-Type" und "Accept" aber es funktioniert immer noch nicht.

Ich versuchte es dann in Postman und auch im Terminal mit den gleichen Headern, aber dieser Fehler ist passiert. enter image description here

Vielen Dank.

Antwort

1

Sie müssen Ihrer Anfrage eine Accept: application/vnd.github.spiderman-preview-Kopfzeile hinzufügen, um auf die Repo Traffic-API zuzugreifen, während sie in der Vorschau angezeigt wird. Aus der 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

Verwandte Themen