0

I'm trying to add a comment to a Google Drive document - the auth tokens and client IDs are all correct (trying to do everything else works), but when adding a comment - I get an error:

code: 400,
  message: 'Resource metadata required',
  data: 
   [ { domain: 'global',
       reason: 'required',
       message: 'Resource metadata required' } ] }

No idea what's going on. I'm sending in a resource that contains { content: 'something' } and also another param for fileId.

Please let me know if you have any ideas.

Thanks!

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Edward Sun
  • 1,541
  • 3
  • 15
  • 26
  • 1
    Try and set the `body` property of the request to ` { content: 'something' }` manually, before calling the `execute` – Niklas Sep 04 '13 at 21:26

3 Answers3

1

This question is old but perhaps someone could still use the solution, like i would have.

I suppose you tried to do it like that:

var request = client.drive.comments.insert({
  'fileId': fileId,
  'resource': body
});

The documentation seems to be outdated for that matter. I had a similar case where I tried to insert a permission. I found another similar problem plus the solution for it in that question.

The right way to do it is:

 var request = client.drive.comments.insert(
   { fileId: fileId }, body
  );
Community
  • 1
  • 1
schummar
  • 1,591
  • 1
  • 9
  • 9
0

Check official documentation for Google Drive API: Comments.insert(). At the bottom of the page, you will see sample code of various languages you can use.

In general, at StackOverflow, if you want better help, specify your question and add your source code and error stack of it.

JunYoung Gwak
  • 2,967
  • 3
  • 21
  • 35
0

It's work for me.

var options = {
        url: 'https://www.googleapis.com/drive/v2/files/' + params.id + '/permissions',
        headers: {
            'Authorization': 'Bearer ' + self.tokens.access_token,
            'Content-Type': 'application/json',
            'Content-Length': JSON.stringify(params.metadata).length
        },
        body: JSON.stringify(params.metadata)
    };
Phong Dao
  • 139
  • 1
  • 1
  • 14