hi out there, I am absolute beginner when it comes to REST. Following the documentation I tried to load an entity with the following code:
String url = "http://localhost:8080/rest/entities/bookstore_EHC_Q_KFZA/" + getEditedEntity().getId() ;
try {
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
String body = response.getBody();
MediaType contentType = response.getHeaders().getContentType();
HttpStatus statusCode = response.getStatusCode();
System.out.println("Erfolgreicher REST-Aufruf");
System.out.println("MediaType:" + contentType.toString());
System.out.println("HttpStatus:" + statusCode.toString());
System.out.println("Body:" + body.toString());
// Process the response...
} catch (RestClientException e) {
// Handle the exception...
System.out.println(e.getMessage());
System.out.println(e.getStackTrace());
}
I receive an error code 401 stating: “{“error”:“unauthorized”,“error_description”:“Full authentication is required to access this resource”}”.
I understood, that I have to POST an authorization request prior to this GET request. Do you have a code sample to do this? The curl-sample in the documentation does not work for me.
Thx for any assistance
Michael