I have the following method for sharing 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 the commenter variable is false (we do not set the add-on roles), but if I want the user to have the role of “reader” and “commentator”, I get the following 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"
}
Has anyone encountered similar problems?
source share