ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

调用同一个API地址,相同的入参,Postman正常,但RestTemplate一直报错:{“ErrorMessage“: “(IndexError) list index out of range“

调用同一个API地址,相同的入参,Postman正常,但RestTemplate一直报错:{“ErrorMessage“: “(IndexError) list index out of range“ 1.问题场景第三方API地址http://124.AA.BBB.205:100方式一通过postman直接传参访问正常方式二通过postman触发springboot的controller接口传值后再通过RestTemplate访问API报错500 INTERNAL SERVER ERROR: {ErrorMessage: (IndexError) list index out of range}2.Postman直接访问正常3.通过Postman访问springboot项目的controller层接口再通过RestTemplate访问API报错4.问题定位及解决方法原因Postman在发送http请求之前会自动在token前面加上前缀Bearer 注意后面有一个空格而RestTemplate没有此功能必须人工声明配置Bearer token属性否则会报错。问题解决。试过okhttp也是一样的效果
返回列表