Reputation: 21
How do I add personFields mask?
My code and error are below
My full code here!
I/onResponse: {
"error": {
"code": 400,
"message": "personFields mask is required. Please specify one or more valid paths. Valid paths are documented at https:\/\/developers.google.com\/people\/api\/rest\/v1\/people\/get.", "status": "INVALID_ARGUMENT"
}
}
Upvotes: 0
Views: 1352
Reputation: 266
Try this
ListConnectionsResponse connectionsResponse = service
.people()
.connections()
.list("people/me")
.set("personFields","names,addresses,birthdays,genders,phoneNumbers,photos")
.execute();
Upvotes: 1
Reputation: 21
Ok i did some research and i found a way to pass the personFields through the post url.I can fetch name gender and emailaddress but i cannot fetch phonenumber even after authorizing access Anybody know why?
OkHttpClient client2 = new OkHttpClient();
final Request request2 = new Request.Builder()
.url("https://people.googleapis.com/v1/people/me?personFields=names,genders,emailAddresses,phoneNumbers")
.addHeader("Authorization", "Bearer " + accessToken)
.build();
Upvotes: 1
Reputation: 174
The solution to your issue is already mentioned in the response of Google People API.
personFields string (FieldMask format)
Required. A field mask to restrict which fields on the person are returned. Valid values are:
So, just add another parameter to you RequestBody with the key 'personFields' and a value from the previous valid values. https://developers.google.com/people/api/rest/v1/people/get
Upvotes: 0