Spring RestTemplate给出"500"错误但URL相同,credentails在RestClient和Curl中有效 [英] Spring RestTemplate gives "500" error but same URL, credentails works in RestClient and Curl
问题描述
一个Url,Credentials在RestClient用户界面以及Curl中都起作用,当通过Spring RestTemplate访问同一URL时,我得到"500"错误.
An Url, Credentials works in RestClient UI as well as with Curl where as i'm getting "500" error when access the same via Spring RestTemplate.
我正在使用以下代码:
MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
map.add("name", user);
map.add("password", password);
restTemplate.postForObject(url, request, Employee.class, map);
请让我知道您的建议或评论,以解决该问题.
Please let me know your suggestions or comments to fix the problem.
推荐答案
以下工作正常
对于帖子:
restTemplate.postForObject(url,parametersMap,Employee.class);
restTemplate.postForObject(url, parametersMap, Employee.class);
url是:字符串-其余api URL parametersMap-MultiValueMap 员工-需要从JSON响应转换的对象
url is : String - rest api URL parametersMap - MultiValueMap Employee - object which needs to be converted from the JSON response
这篇关于Spring RestTemplate给出"500"错误但URL相同,credentails在RestClient和Curl中有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!