Acumatica REST API客户无法通过RestTemplate使用客户ID中带有&符号的URL进行工作

向Acumatica REST API发出的Spring RestTemplate请求,当客户ID在请求中发送的客户ID之间使用&符时,客户将无法工作

我什至尝试在以下givne中用%26替换&并将其在Postman工具中工作,但在使用RestTemplate Object从Spring应用程序中尝试时不起作用

使用RestTemplate对象在邮递员中工作但在我的Spring应用程序中不工作的网址是https://acumatica.kimballinc.com/AcumaticaERP/entity/sprestprod/6.00.001/Customer?$ filter = CustomerID eq'WESTECH FUEL%26 EQUIP'&$ expand = MainContact / Address,ShippingContact / Address

使用的Java Spring Application代码是

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("authorization","Bearer iuwnsne9383nx,sowejwew");
HttpEntity<String> header = new HttpEntity<String>(headers);
RestTemplate restTemplate = new RestTemplate();
String url = "https://acumatica.kimballinc.com/AcumaticaERP/entity/sprestprod/6.00.001/Customer?$filter=CustomerID eq 'WESTECH FUEL %26 EQUIP'&$expand=MainContact/Address,ShippingContact/Address"
restTemplate.exchange(url,HttpMethod.GET,header,AcumaticaCustomerVO[].class);
sajensenhanyya 回答:Acumatica REST API客户无法通过RestTemplate使用客户ID中带有&符号的URL进行工作

我相信RestTemplate搞砸了URL编码方案。

似乎有解决方法:

  1. 将StringHttpMessageConverter添加到模板的消息转换器中:https://stackoverflow.com/a/28742831/7376238

  2. 避免进行RestTemplate交换调用,而是使用UriComponentsBuilder构造URI:https://stackoverflow.com/a/56027025/7376238

本文链接:https://www.f2er.com/2987319.html

大家都在问