Reputation: 119
Trying to use the GDrive API to create a comment on in a Google Sheets file and receiving the following error:
Google.Apis.Requests.RequestError The 'fields' parameter is required for this method. [400] Errors[ Message[The 'fields' parameter is required for this method.] Location[fields - parameter] Reason[required] Domain[global] ]
Not sure where to specify the fields parameter?
I've tried searching for where to put the parameter and looked at both v2 and v3 documentation neither of which indicates a need to specify a fields parameter.
Below is the code I'm working with:
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;
Upvotes: 0
Views: 236
Reputation: 119
Welp, I've managed to plow through my own code and solved it. I figured out where to specify the fields parameter and am just spitting the response to a string for now. I commented out the anchor, since I don't yet know its structure (the anchor shown is what google shows when I do a Get Comment by 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);
Upvotes: 1