百度智能识别时返回error_code: 216101

635 阅读1分钟

请求百度接口出现标题错误代码

我调用的是车辆定损的接口,一直报错。

后来在postman测试,发现from-data的方式请求ok

由于我用的是axios,然后再mian配置一下(也可以自己配置请求拦截)

main.js

<!--先引入axios这一步不用讲啦-->
import axios from 'axios'

<!--from-data的方式请求-->
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.headers.get['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.transformRequest = [function (data) {
let ret = ''
for (let it in data) {
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
}
return ret
}]
<!--挂在原型上-->
Vue.Prototype.$axios = axios 

然后在需要直接请求就可以了!