The rest api requires basic authorization for a POST to the group roles but it's not explicitly stated in the API documentation. So here's how I got it to work:
String auth = "username:password";
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US_ASCII")));
String authHeader = "Basic " + new String(encodedAuth);
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(url);
StringEntity input;
try {
input = new StringEntity("{\"group\":\"your-jira-group\"}");
input.setContentType("Application/json");
post.setEntity(input);
post.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
HttpResponse response = client.execute(post);
} catch (Exception ex) {
}
Two things were messing me up...the "A" in Application/json needed to be capitalized and you needed to authorize the session. I chose basic authentication and used HttpClient after testing it with curl.