Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 77 characters in body; edited tags
Source Link
MPelletier
  • 16.8k
  • 18
  • 90
  • 140
 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;  } 
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" }  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? Could anyone help me?

Thanks

 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;  } 
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? Could anyone help me?

Thanks

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; } 
 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?

Source Link

Google Drive API Java Permissions 500 Internal Error

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? Could anyone help me?

Thanks