我在Meteor中使用github API,但无法解决此问题:
此代码尝试获取某个存储库的总流量。
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);
}
});错误:
{
"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"
}我搜索了类似的问题并添加了"Content-Type“和"Accept”,但它仍然不起作用。
然后,我尝试在Postman和终端中使用相同的标头执行此操作,但此错误不断发生。

非常感谢。
发布于 2016-09-16 20:37:56
您需要将Accept: application/vnd.github.spiderman-preview标头添加到您的请求中,以便在预览表单中访问Repo Traffic API。从API docs
用于存储库流量的
API目前可供开发人员预览。在预览期内,API可能会有更改,恕不另行通知。有关详细信息,请参阅博客文章。
要访问API,您必须在Accept标头中提供自定义媒体类型:
application/vnd.github.spiderman-preview
发布于 2021-09-15 16:34:38
提交搜索API目前可供开发人员预览。在预览期内,API可能会有更改,恕不另行通知。
要访问API,您必须在Accept标头中提供自定义媒体类型:
Accept: application/vnd.github.cloak-preview☝️此标头是必需的。
发布于 2021-10-21 08:24:07
对于在发送POST请求时GitLab应用程序接口开始抛出415的原因,最后出现在此页面的任何人:
如果要通过post数据字段发送内容,请确保传递Content-Type: application/x-www-form-urlencoded标头。他们的文档从来没有提到这个b/c,显然很多客户端(比如curl)都会自动这么做。
https://stackoverflow.com/questions/39338126
复制相似问题