I have the next method to share Google Drive files:
public static boolean shareFile(HttpServletRequest httpReq, String fileId, String user, String rol, boolean commenter) {
Drive service = getService(httpReq) ;
if (service != null){
Permission newPermission = new Permission();
newPermission.setValue(user);
newPermission.setType("user");
newPermission.setRole(rol);
if (commenter)
newPermission.setAdditionalRoles(Arrays.asList("commenter"));
try {
service.permissions().insert(fileId, newPermission).execute();
return true;
} catch (Exception e) {
System.out.println("An error occured: " + e);
}
}
return false;
}
Everything works fine when variable commenter is false (we don't set addiotional roles), but if I want a user to have role "reader" and "commenter" I get the next error:
An error occured: com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Internal Error",
"reason" : "internalError"
} ],
"message" : "Internal Error"
}
Did anyone experience with this kind of problem?