【问题标题】:Error trying to Create Comment on GDrive API v3尝试在 GDrive API v3 上创建评论时出错
【发布时间】:2019-01-11 17:25:04
【问题描述】:

尝试使用 GDrive API 在 Google 表格文件中创建评论并收到以下错误:

Google.Apis.Requests.RequestError 此方法需要 'fields' 参数。 [400] 错误[ 消息[此方法需要 'fields' 参数。] 位置[字段 - 参数] 原因[必需] 域[全局] ]

不确定在哪里指定 fields 参数?

我尝试搜索放置参数的位置,并查看了 v2 和 v3 文档,这两个文档都没有表明需要指定字段参数。

下面是我正在使用的代码:

string result = "success";
try {
    Comment oBody = new Comment {
        Content = commentText,
        Anchor = "{'r': 0, 'a': [{'matrix':{'c': 4}},  {'matrix':{'r': 4}}]}"
    };
    Comment oRequest = driveService.Comments.Create(oBody, fileId).Execute();
} catch (Exception e) {
    result = "Google API: " + e.Message;
}
textBox1.Text = result;
return result;

【问题讨论】:

    标签: c# google-drive-api


    【解决方案1】:

    Welp,我已经设法通过自己的代码并解决了它。我想出了在哪里指定 fields 参数,现在只是将响应吐出到一个字符串。我注释掉了锚点,因为我还不知道它的结构(显示的锚点是谷歌在我通过 Id 获取评论时显示的内容)。

    Comment oBody = new Comment {
        Content = commentText,
        //Anchor = "{\"type\":\"workbook-range\",\"uid\":0,\"range\":\"1561003787\"}",
    };
    CommentsResource.CreateRequest oRequest = driveService.Comments.Create(oBody, fileId);
    oRequest.Fields = ("*");
    Comment oResponse = oRequest.Execute();
    result = JsonConvert.SerializeObject(oResponse, Formatting.Indented);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-10
      • 2013-08-01
      • 1970-01-01
      • 2021-10-02
      • 1970-01-01
      • 2019-12-17
      • 1970-01-01
      • 2015-08-23
      相关资源
      最近更新 更多