简体   繁体   English

Spring restTemplate 不适用于 URL 中的单引号。 与邮递员一起工作

[英]Spring restTemplate not working for single quotes in URL. Works with postman

Simple restTemplate exchange used for a GET request.用于 GET 请求的简单 restTemplate 交换。

Header information标题信息

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'

I tried building this URL with either MessageFormat.format or URIBuilder .我尝试使用MessageFormat.formatURIBuilder构建此 URL。 The single quotes are the problem.单引号是问题。 So far I tried double-ing them, escaping them or leaving them as they are.到目前为止,我尝试将它们加倍,逃避它们或让它们保持原样。

I enabled some extra logging with : logging.level.org.springframework.web.client.RestTemplate=DEBUG This displays the URL.. if I copy that URL and paste it in POSTMAN, I receive results, from spring I receive 400 Bad request.我启用了一些额外的日志记录: logging.level.org.springframework.web.client.RestTemplate=DEBUG 这会显示 URL .. 如果我复制该 URL 并将其粘贴到 POSTMAN 中,我会收到结果,从 spring 我收到 400 Bad request .

I suppose it might be some additional encoding to blame.我想这可能是一些额外的编码。 Any ideas?有什么想法吗?

  • The JWT had way to many scopes, the server API decided to throw a 400 without any message and the server logs were not available.. JWT 有很多范围,服务器 API 决定抛出 400 没有任何消息并且服务器日志不可用。
  • A flag in application.properties that sets the maximum header size. application.properties中的一个标志,用于设置最大标头大小。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 REST POST 与 POSTMAN 一起正常工作,但在使用 Spring RestTemplate 时出现异常 - REST POST works correctly with POSTMAN but exception when using Spring RestTemplate Java Spring RestTemplate POST问题,而Postman工作 - Java Spring RestTemplate POST issue, while Postman works RestTemplate 交换超时但 PostMan 有效 - RestTemplate Exchange Timeouts but PostMan Works AWS API Gateway - 在Java中使用Spring RestTemplate访问API时的连接超时,使用Postman可以正常工作 - AWS API Gateway - Connection timeout on accessing API using Spring RestTemplate in Java where it works fine using Postman Spring RestTemplate 给出 $InternalServerError: 500 null。 在 POSTMAN 和 SMALL FILES 中同样有效 - Spring RestTemplate gives $InternalServerError: 500 null. Same works in POSTMAN and for SMALL FILES Spring Boot restTemplate POST请求bad_certificate,但在SOAPUI和Postman中有效 - Spring Boot restTemplate POST request bad_certificate, but works in SOAPUI and Postman "spring resttemplate url编码" - spring resttemplate url encoding GET 请求适用于 Postman,但不适用于 SpringBoot RestTemplate - GET Request Works in Postman but not with SpringBoot RestTemplate azure 逻辑应用程序请求触发器 url 在 RestTemplate java 中不起作用,但在 postman 中起作用 - azure logic app request trigger url is not working from RestTemplate java but working in postman Spring RestTemplate不起作用 - Spring RestTemplate not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM