4

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?

1 Answer 1

1

I got this kind of error if passed id field is not correct. Strange error code, i think something like 4XX is more suitable here (not 500).

100% reproducible.

Request:

POST https://www.googleapis.com/drive/v2/files/0B28tlN6SgYRaNVRFRENpRFN3bGs/permissions?key={YOUR_API_KEY} { "role": "reader", "type": "user", "id": "16887416236869940585" } 

Response:

500 Internal Server Error { "error": { "errors": [ { "domain": "global", "reason": "internalError", "message": "Internal Error" } ], "code": 500, "message": "Internal Error" } } 

Hope Google Drive API error messaging will be more informative that (500 Internal Server Error).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.