问题
with people.api I can only read the people in the main group, with people.connections.list:
GET https://people.googleapis.com/v1/people/Me/connections
with MS REST.api I can also read the people in a sub-group
GET https://outlook.office.com/api/v2.0/me/contacts
GET https://outlook.office.com/api/v2.0/me/contactfolders/{contact_folder_id}/contact
I know that I can use contactGroups.get to find the resource names. But then I need one people.get request for each resource name.
Unfortunately, this is not possible because the maximum number of allowed requests will then be exceeded very quickly (75 / min).
So what's the solution?
回答1:
Answer:
You can use the people.getBatchGet
end point to make a batch request to the API and get multiple resources in one request.
More Information:
After using the contactGroups.get
call to get the resource IDs you can use the batch request method to get multiple responses at once. Using:
GET https://people.googleapis.com/v1/people:batchGet
as your endpoint, and specifying which personFields
you wish to get from the resourceNames
.
You can test it on the Try This API feature of people.getBatchGet
here. Each resourceName
is in the form people/cXXXXXXXXXXXXXXXXXXX
which you obtain from the contactGroups.get
response.
Please note, as per the documentation:
You can include up to 50 resource names in one request.
Example resource:
{
"personFields": "emailAddresses",
"resourceNames": [
"people/c1111111111111111111",
"people/c2222222222222222222",
"people/c3333333333333333333"
]
}
I hope this is helpful to you!
References:
- People API - contactGroups.get method
- People API - people.getBatchGet method
来源:https://stackoverflow.com/questions/59937357/google-people-api-how-to-get-members-of-a-specific-group