Missing required field: member

2019-07-28 10:26发布

{ 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 request:

var request = client.admin.members.insert({
    groupKey: "some_group@example.com"
  , email: "me@example.com"
});

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.

2条回答
淡お忘
2楼-- · 2019-07-28 11:08

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: "some_group@example.com"
}, {
    email: "me@example.com"
});
查看更多
可以哭但决不认输i
3楼-- · 2019-07-28 11:28

The documentation at https://developers.google.com/admin-sdk/directory/v1/reference/members/insert for admin.members.insert indicates that it requires a groupKey parameter, but that the body (which the node.js library handles as a separate object) should contain a members object containing the role property. See the API Explorer a the bottom of that page as well.

查看更多
登录 后发表回答