java - Spring RestTemplate can not convert json response -
i have url - http://hzhzhz
return json
{ "somefield": 3, "datesfield": ["2017-08-19", "2017-08-20", "2017-08-26", "2018-12-30"] } i create models
@data @noargsconstructor private class response{ private int somefield; private datesfield datesfield; } @data @noargsconstructor private class datesfield{ private list<string> strings; } i create
responseforobject = resttemplate.getforobject("http://hzhzhz", response.class); amd error:
could not extract response: no suitable httpmessageconverter found response type [class mypackeg.response] , content type [text/html;charset=utf-8]
your "http://hzhzhz" call returns html cannot converted mypackeg.response class.
could url wrong or produces wrong content type (html instead of expected json or xml). fix try return string.class , check in string.
one more possible reason permission denied returns access denied html page.
Comments
Post a Comment