发布时间:2018-10-17作者:laosun阅读(3489)
{"failures":[{"code":8603,"position":"_sys","message":"The request header you provided is invalid. sn:1154059563220900608"}],"desc":"system failure","status":3}
最近拉取百度统计API出现了异常,下边返回json串的信息:
{"failures":[{"code":8603,"position":"_sys","message":"The request header you provided is invalid. sn:1154059563220900608"}],"desc":"system failure","status":3}
说什么请求头无效不合法。
但是百度发送json串那块已经分为header和body两个区域,所以很容易迷糊人。看了半天文档,发现没问题,也没有发布新的文档,那么不是这个header,就是request 请求头的header了。
经常从网上查找资料,发现有人说是header头中需要增加Content-type:application/json
就这么简单,百度没有任何的通知,看来是不注重这块。
我的代码是怎么增加的。如下所示:
Map<String, String> headers = new HashMap<>(); headers.put("Content-type", "application/json"); String result = HttpKit.post(url, params.toString(), headers);
在发送请求的时候带着这个头即可解决。
版权属于: 技术客
原文地址: https://www.sunjs.com/article/detail/204e88fcab9944ea8c847f39667043ec.html
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
关键字: Java