springboot java调用flask python写的

服务a用flask,服务b用的springboot,服务a写的接口,用python很容易就调通了,java来调,坑有点多

1、url最后的斜杠必须两边对应上,否则flask会先308,而且 content type [text/html;charset=utf-8],连对应的HttpMessageConverter都没有

org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [com.api.ApiResponse<java.lang.String>] and content type [text/html;charset=utf-8]

2、get请求的参数传递,

两种方式,一是uri参数

如/api/v1/test/{code}}
restTemplate.exchange(URL, HttpMethod.GET, new HttpEntity(), new ParameterizedTypeReference<ApiResponse<List>>() {
}, code);

另一种,接在uri上,如如/api/v1/test/?code=358

restTemplate.exchange(URL, HttpMethod.GET, new HttpEntity

posted @ 2024-04-19 18:47  木头左  阅读(88)  评论(0编辑  收藏  举报