首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >github API不支持的媒体类型415

github API不支持的媒体类型415
EN

Stack Overflow用户
提问于 2016-09-06 05:55:19
回答 3查看 3.8K关注 0票数 3

我在Meteor中使用github API,但无法解决此问题:

此代码尝试获取某个存储库的总流量。

代码语言:javascript
复制
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);
  }
});

错误:

代码语言:javascript
复制
{
  "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和终端中使用相同的标头执行此操作,但此错误不断发生。

非常感谢。

EN

回答 3

Stack Overflow用户

发布于 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

票数 6
EN

Stack Overflow用户

发布于 2021-09-15 16:34:38

提交搜索API目前可供开发人员预览。在预览期内,API可能会有更改,恕不另行通知。

要访问API,您必须在Accept标头中提供自定义媒体类型:

代码语言:javascript
复制
 Accept: application/vnd.github.cloak-preview

☝️此标头是必需的。

check docs

票数 0
EN

Stack Overflow用户

发布于 2021-10-21 08:24:07

对于在发送POST请求时GitLab应用程序接口开始抛出415的原因,最后出现在此页面的任何人:

如果要通过post数据字段发送内容,请确保传递Content-Type: application/x-www-form-urlencoded标头。他们的文档从来没有提到这个b/c,显然很多客户端(比如curl)都会自动这么做。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39338126

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档