I am connecting to SharePoint to query lists, all was well but now I get a HTTP/1.1 500 Internal Server Error for the same request which was ok and tested. I guess the problem is from a configuration.
The response I get is
The Web application at http://hostname:80/my/personal/incorta/_api/web/lists could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
I was following https://stackoverflow.com/questions/29570383/basic-authentication-from-java-to-sharepoint-2013-rest-api/29609502#29609502 and I was getting the correct response my code as follow
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope(AuthScope.ANY),
new NTCredentials("USERNAME", "PASSWORD", "https://HOSTNAME", "DOMAIN"));
CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultCredentialsProvider(credsProvider)
.build();
try {
HttpGet httpget = new HttpGet("http://hostname/_api/web/lists");
httpget.setHeader("Accept", "application/json;odata=verbose");
System.out.println("Executing request " + httpget.getRequestLine());
CloseableHttpResponse response = httpclient.execute(httpget);
try {
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println(result);
EntityUtils.consume(response.getEntity());
} finally {
response.close();
}
} finally {
httpclient.close();
}