Google-api-nodejs-client: 400 - Missing required field: member

Created on 31 Mar 2014  路  6Comments  路  Source: googleapis/google-api-nodejs-client

{ errors: 
   [ { domain: 'global',
       reason: 'required',
       message: 'Missing required field: member' } ],
  code: 400,
  message: 'Missing required field: member' }

I get this error when I run the following:

var request = client.admin.members.insert({
    groupKey: "[email protected]"
  , email: "[email protected]"
});

I was authenticated successfully (I received the access token and so on) but when I execute the request above it callbacks that error.

What member field am I supposed to add?

It works fine in API Explorer using groupKey and email fields.

triage me

Most helpful comment

I struggled with the same issue. Had to do this to get it working

client.members.insert({
  auth: jwtClient,
  groupKey: '[email protected]',
  resource: {
    email: '[email protected]'
  }
}, function(err, res) { });

Seems like the syntax changed since the thread above?

All 6 comments

email is part of the form data. The form data must be passed as object in the second argument:

// create the group insert request
var request = client.admin.members.insert({
    groupKey: "[email protected]"
}, {
    email: "[email protected]"
});

@rakyll Can you confirm this?

Yes, the latter snippet looks correct. Anything goes into the body on the API Explorer should be on the second argument.

Thanks! :smiley:

Anything goes into the body on the API Explorer should be on the second argument.

This needs to be documented better.

I struggled with the same issue. Had to do this to get it working

client.members.insert({
  auth: jwtClient,
  groupKey: '[email protected]',
  resource: {
    email: '[email protected]'
  }
}, function(err, res) { });

Seems like the syntax changed since the thread above?

Update, use like this now*

const response = await directory.groups.insert(
      {
        auth: jwtClient,
        resource: {
          name: "Foo Foo",
          email: '[email protected]'
        }
      }
    );
Was this page helpful?
0 / 5 - 0 ratings