1

** Update: Looks like my question may be a duplicate. I've been working on this a little over a day and did some heavy searching prior but just stumbled across this (Google Drive API call to insert Public Share permissions on Fusiontables causes Internal Error) which seems to suggest that this is a bug with Drive Permissions for Fusion Tables. At the time being I would like to leave this open to wait on a response from @pinoyyid. Additionally, I'd appreciate knowing whether I should close this or mark it a duplicate, given my recent find.


I found this resource which documents a similar workflow but not in the JavaScript Client API: Set file sharing level to 'Anyone with the link' through Google Drive API

In attempting the same process with the JS Client API (see my code below), I continue to receive 500's. The error, I believe, has to do with what value I give to the value key. I've tried every variation I can imagine, but to no avail. Thanks much in advance.

            var request = gapi.client.drive.permissions.insert({
              'fileId'   : tracker_id,
              'resource' : {
                            'value'    : '',
                            'type'     : 'anyone',
                            'role'     : 'reader',
                            'withLink' : true,
                           },
            });
            request.execute(function(executed) { console.log(executed) });  

Update: I just found this posting: Google Drive API: How do you insert permissions to make a document publicly readable?

It appears this user may have been using the JS Client API as well... Unfortunately the method posted in that quesiton/answer continues to render 500 responses for me. If anyone happens to know why, I would appreciate the help.

Community
  • 1
  • 1
kuanb
  • 1,618
  • 2
  • 20
  • 42
  • Take out the comma after the resource.'resource' : { 'value' : '', 'type' : 'anyone', 'role' : 'reader', 'withLink' : true, } // Here if you give comma it expects one more parameter. This should resolve your issue. – SGC May 06 '15 at 20:51
  • Thanks, @SGC, but this does not resolve the issue. – kuanb May 07 '15 at 02:39

1 Answers1

1

Try removing the value='' line altogether. There is a difference between a zero length string and undefined. If that doesn't work, post the full http post and response from your browser dev console so we can see what's on the wire and the 500 error text.

As an aside, is this an AngularJS app?

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • Thanks for the response @pinoyyid. Not using Angular at the moment (will be in the future, likely). Unfortunately, I have tried a number of variations, none of which seem to be successful for the 'results' key dict value. I have tried `value` totally remove, set to `null`, set to `''`, set to 'me', set to 'anyone', and a variety of other grasps in the dark. All have been performed, to no avail. – kuanb May 07 '15 at 02:43
  • Here was the HTTP Post: `https://content.googleapis.com/drive/v2/files/XXXXXXXXXXXXXX/permissions?alt=json&key=XXXXXXXXXXXXXX` Here was the Response: ```{ "error": { "errors": [ { "domain": "global", "reason": "internalError", "message": "Internal Error" } ], "code": 500, "message": "Internal Error" } } ``` – kuanb May 07 '15 at 02:45
  • Could you also paste the post body. – pinoyyid May 07 '15 at 07:47
  • Query string params: `alt=json&key=XXXXXXXXXXXXX`. Request payload: `{"value":"","type":"anyone","role":"reader","withLink":true}`. (Bear in mind the fact that multiple values for `value` have been attempted.) – kuanb May 07 '15 at 14:01
  • I think my question may be a duplicate of http://stackoverflow.com/questions/26761199/google-drive-api-call-to-insert-public-share-permissions-on-fusiontables-causes – kuanb May 07 '15 at 15:19