我使用 Rest Template 來使用 Rest Web 服務,但是我總是得到 500 雖然當我與郵遞員一起測驗時我得到 200
這是 Rest 模板代碼:
private String callWs(int page) {
final HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.USER_AGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36");
headers.add(HttpHeaders.ACCEPT, "*/*");
headers.add(HttpHeaders.ACCEPT_ENCODING, "gzip, deflate, br");
headers.add(HttpHeaders.CONNECTION, "keep-alive");
headers.add(HttpHeaders.COOKIE, "country-code=MA");
headers.add(HttpHeaders.CACHE_CONTROL, "no-cache");
final HttpEntity<?> entity = new HttpEntity<>(headers);
final String urlTemplate = UriComponentsBuilder.fromHttpUrl(BASE_URL2)
.queryParam("action", "ajax")
.queryParam("rs", "JsonCategories")
.queryParam("rsargs[]", "1")
.queryParam("rsargs[]", "???????_??????_????")
.encode()
.toUriString();
final ResponseEntity<String> exchange = restTemplate.exchange(
urlTemplate,
HttpMethod.GET,
entity,
String.class);
return exchange.getBody();
}
郵遞員回復:

休息模板錯誤:
There was an unexpected error (type=Internal Server Error, status=500).
500 Internal Server Error: [Exception encountered, of type "ArgumentCountError" ]
org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Internal Server Error: [Exception encountered, of type "ArgumentCountError"
]
uj5u.com熱心網友回復:
嘗試在一個引數中傳遞陣列,rsargs[]而不是像您那樣傳遞兩個引數。
.queryParam("rsargs[]", new String[]{"1", "???????_??????_????"})
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/344075.html
上一篇:這個奇怪的路徑語法是什么?
