PostMan报415Unsupported Media Type

在一次对接API过程中,调试接口时PostMan报"415Unsupported Media Type"状态码,搞了好几天没通,API响应结果始终是415,下面是我在PostMan中的配置:
在这里插入图片描述
在这里插入图片描述
响应的Json数据:

{
    "Message": "The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource.",
    "ExceptionMessage": "No MediaTypeFormatter is available to read an object of type 'AvailableRatesRequest' from content with media type 'application/octet-stream'.",
    "ExceptionType": "System.Net.Http.UnsupportedMediaTypeException",
    "StackTrace": "   at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n   at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)"
}

有一天早上我试着将Body Raw中的Json数据删了,诶~,PostMan不再提示415了,状态码也变成了"200 OK"了,从API返回的Json信息可以看出是缺少参数,根据提示信息试着将参数配置到"x-www-form-urlencoded"中,没毛病,剩下的就是Json中的数据的问题了
在这里插入图片描述
在这里插入图片描述

总结一下一直调不通的原因:
    API文档上面提到URL、Header、Method应该怎么配置,并未提及Json应该放在哪个位置,好在他们那边有提示信息,不然谁知道这Json应该怎么配置,怕只有API开发商那边才知道,所以在调试这些接口时如果调不通可以试着一个一个的删除配置信息,来缩小产生这个错误的原因。如果试过了所有方法还是调不通,那唯一的办法就是咨询API开发商了。
在这里插入图片描述

    由于出现http 415的原因很多,因此以上解决方法并不一定能解决所有415问题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值