0
votes

I want to upgrade my little tool from google contact api to google people api. The authorization is working and I get contacts from peopeService. But the person.Metadata source item array has only one item type "CONTACT". I do miss the 'updateTime' in person.Metadata.Sources. The code snipped:

PeopleResource.ConnectionsResource.ListRequest peopleRequest =
   peopleService.People.Connections.List("people/me");

if (pageToken != null)
{
   peopleRequest.PageToken = pageToken;
}

peopleRequest.RequestMaskIncludeField = 
   person.names,person.organizations,person.birthdays,person.biographies, 
   person.emailAddresses,person.Metadata,person.PhoneNumbers,person.Addresses,
   person.userDefined";
ListConnectionsResponse people = peopleRequest.Execute();

if (people != null && people.Connections != null && people.Connections.Count > 0)
{
   foreach (var person in people.Connections)
   {
      ConvertGooglePerson2ContactItem(person);
   }

   if (people.NextPageToken != null)
   {
      GetAllContactItems(people.NextPageToken);
   }
}

Get Source data:

if (person.Metadata!=null)
foreach (var item in person.Metadata.Sources)
{
...
}

Screenshot of debug session: Empty Metadata.Sources

Maybe this is an issue with the query parameters Link. But I don't know how to set this query parameter.

-------- added on Jan 6 '21 as questions of comments --------

I have tried this API: https://developers.google.com/people/api/rest/v1/people.connections/list

With both fields set: personFields and requestMask.includeField:

400 Bad Request
{
  "error": {
    "code": 400,
    "message": "Please specify only one of requestMask or personFields.",
    "status": "INVALID_ARGUMENT"
  }
}

The result of personFields only please see questions.

The metaData with personFields only of person was given:

      "resourceName": "people/c623380167042605258",
      "etag": "%Eg4BAj0FBwk+Cz8MEEA3LhoEAQIFByIMcG9JRnpDRzBxS0U9",
      "metadata": {
        "sources": [
          {
            "type": "CONTACT",
            "id": "8a6b0f5889920ca",
            "etag": "#poIFzCG0qKE=",
            "updateTime": "2021-01-04T22:44:04.913Z"
          }
        ],
        "objectType": "PERSON"
      },

Maybe it's an API problem?

How can I get last modified time of the people contact?

1
I'm not sure I fully understand the problem. Using the people.connections.list method you can retrieve the updateTime by default. It is located in the JSON response at connections/metadata/sources/updateTime.Rafa Guillermo
You can check out this example which uses the Try this API feature to see that the updateTime is returned.Rafa Guillermo
Also, there are more types than just CONTACT for the person.metadata.source enum. You can see these here.Rafa Guillermo
@Rafa Guillermo I have added a screenshot of debug session. The Metadata.Source Array contains only one item type "CONTACT". I expect more entries here among others the update time. Is this an issue of the RequestMaskIncludeField or other request parameters?AndreasU
Where are you specifying the personFields mask for your request? Did you check out the Try This API feature to see if this is reproducible?Rafa Guillermo

1 Answers

0
votes

The request is solved with this code snippet:

var updateTime = person.Metadata.Sources.FirstOrDefault().UpdateTime;

Be sure using the Google.Apis.PeopleService.v1 Google APIs Client Library in your project.