Hello
I'm using the java admin client (org.keycloak.admin.client.Keycloak) to create new keycloak users.
Sometimes user creation failed, so I try to retrieve the response entity. Which java class can I use to deserialize the actual json response body content? I'm currently simply using String.class, is there a specific keycloak "error message" class?
// create keycloak user
try (final Response userCreationResponse = this.keycloakUsersResource.create(keycloakUser)) {
try {
keycloakUserId = CreatedResponseUtil.getCreatedId(userCreationResponse);
} catch (final WebApplicationException e) {
final String responseBody = userCreationResponse.readEntity(String.class);
log.error("error during keycloak user creation: {}, {}", e.getMessage(), responseBody, e);
throw e;
}
}
Some example of retrieved strings:
{"error":"unknown_error"} , with HTTP 500 status
{"errorMessage":"User exists with same username"} , with HTTP 409 status
Regards
Thomas LIMIN