Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: 'fields' parameter is required for this method

Google API: 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]
]

I'm trying to use the About resource in the Google Drive API (.v3) and receiving an error I can't seem to resolve, that isn't answered in documentation. I've spent a few days researching to no avail and don't quite understand what the error message is telling me. New to using the API. :)

P. S. oRequest.Fields does not exist. Tried that too.

string result = "success";
try {
    About oRequest = driveService.About.Get().Execute();
    result = result + oRequest.User;
} catch (Exception e) {
    result = "Google API: " + e.Message;
}
textBox1.Text = result;
return result;

Updated: The code below is an improvement, but produces "Object reference not set to an instance of an object" on the result line... :\

AboutResource.GetRequest oRequest = driveService.About.Get();
oRequest.Fields = "user:displayName, user:permissionId, user:emailAddress";
About oResponse = oRequest.Execute();
result = oResponse.User.DisplayName + " | " + oResponse.User.PermissionId + " | " + oResponse.User.EmailAddress;
like image 381
AWizardInDallas Avatar asked Nov 02 '25 05:11

AWizardInDallas


1 Answers

You can also request a full User object Google.Apis.Drive.v3.Data.User, if you use "user" as field.

For example:

var request = service.About.Get();
request.Fields = "user";
var user = request.Execute().User;

Instead of getting a full response object Google.Apis.Drive.v3.Data.About

like image 175
ganchito55 Avatar answered Nov 03 '25 21:11

ganchito55



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!