Add group via keycloak admin client return 400 status code

Hi all,

public Response createGroup(String groupName) {
		try {
			GroupsResource groupsResource =  keycloak.realm("quarkus").groups();
			
			GroupRepresentation group = new GroupRepresentation();
			group.setName("test");
			Response test = groupsResource.add(group);
		//	List<GroupRepresentation> listGroup = groupsResource.groups();
		
			return test;					
		} catch (Exception e) {
			e.printStackTrace();
			return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Failed to add group")
					.build();
		}
		
	}

I tried to add group using keycloak admin api as showing in above code.
Unfortunately, i got an http 400 error as below using Postman

I already try to find solution on google but nothing found. Hope anyone can help.

Thanks

Use ObjectMapper and:
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)

Using keycloak admin client seem not working.

So i decide to use REST client

	public Response createGroup(String groupName) {
		try {
			AccessTokenResponse token = keycloak.tokenManager().getAccessToken();
			Client client = ClientBuilder.newClient();
			Response response = client.target(serverUrl + "/admin/realms/" + clientRealm + "/groups")
					.request(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token.getToken())
					.post(Entity.json("{\"name\":\"" + groupName + "\"}"));
			return response;
		} catch (Exception e) {
			e.printStackTrace();
			return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Failed to add group").build();
		}

	}