Spring restTemplate不能用于URL中的单引号。与postman一起工作

问题描述 投票:1回答:1

用于GET请求的简单restTemplate交换。

头信息

HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.ALL));
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
headers.add("Authorization",  ************);

URL。

/api/odata/GetAvailableObjects?fromTime=datetime'2018-02-02T12:00:00'&$format=json&toTime=datetime'2018-02-10T12:00:00'

我试着用以下两种方法建立这个URL MessageFormat.formatURIBuilder. 单引号是问题所在。到目前为止,我尝试了双引号、转义或者保持原样。

我启用了一些额外的日志记录:logging.level.org.springframework.web.client.RestTemplate=DEBUG这将显示URL......如果我复制该URL并将其粘贴到POSTMAN中,我收到的结果是,从spring中我收到400个Bad request。

我想可能是一些额外的编码造成的,有什么想法吗?

java spring resttemplate messageformat
1个回答
0
投票
  • JWT有太多的作用域,服务器API决定抛出一个400,没有任何消息,服务器日志也不可用。
  • 一个标志在 application.properties 设置最大的标题尺寸。
© www.soinside.com 2019 - 2024. All rights reserved.