I am making simple request from Spring Boot app to URL.
URL url = new URL("http://...:8001/api/meta");
HttpURLConnection urlConnect = (HttpURLConnection) url.openConnection();
int code = urlConnect.getResponseCode();
...
code = 500. Then an error occurs:
Server returned HTTP response code: 500.
Also urlConnect.getErrorStream = null
If I put the url to browser then I successfully get json.
What should be done to fix the issue?
I have added:
urlConnect.setRequestProperty("Accept", "application/json");
then I can successfully get the response.