0

When creating/updating contact through microsoft graph api - I get lastModifiedDateTime in response and I save it to database but when I fetch all contacts through microsoft graph explorer I see same lastModifiedDateTime for same contact differ by 2 sec or more sec.

Example:

$contacts = $graph->createRequest('POST','/me/contacts')
    ->attachBody($con)
    ->setReturnType(Model\Contact::class)
    ->execute();

Response :

Array(
[olContactId] => AAMkADVmMTRhZGJjLTA0M2QtNGQzNC05MTc3LWYyY2U5NzMyOTg1MQBGAAAAAACHIssaHsI3TKs7eI4Gh3QABwC7sB1Db4_xRaYWdzPkFNNLAAAAAAEOAAC7sB1Db4_xRaYWdzPkFNNLAADcWQhkAAA=
[olLastModDateTime] => 2020-02-12T12:14:54Z)

when getting same contact using graph explorer:

"id":"AAMkADVmMTRhZGJjLTA0M2QtNGQzNC05MTc3LWYyY2U5NzMyOTg1MQBGAAAAAACHIssaHsI3TKs7eI4Gh3QABwC7sB1Db4_xRaYWdzPkFNNLAAAAAAEOAAC7sB1Db4_xRaYWdzPkFNNLAADcWQhkAAA=", "lastModifiedDateTime":"2020-02-12T12:14:55Z",

please help friends

am.dev
  • 25
  • 4

1 Answers1

0

Based on my test, I just got consistent results.

Code:

<?php

require __DIR__.'/vendor/autoload.php';

use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;

$accessToken = 'token_you_get';
// Create a Graph client
$graph = new Graph();
$graph->setAccessToken($accessToken);


$con = array(
    'givenName' => 'jack',
    'surname' => 'Jia',
    'emailAddresses' => array(array('address'=>'jack@hanxia.onmicrosoft.com','name'=>'Jack Jia')),
    'businessPhones' => array('businessPhones')
);

// echo json_encode($con);

// Create
$response = $graph->createRequest('POST','/me/contacts')
    ->attachBody($con)
    ->setReturnType(Model\Contact::class)
    ->execute();

//print_r($response);
print_r(json_encode($response));

?>

Output:

{"@odata.context":"https:\/\/graph.microsoft.com\/v1.0\/$metadata#users('ab6d4cd6-fc2d-40c7-a676-f8773aebfb5f')\/contacts\/$entity","@odata.etag":"W\/\"EQAAABYAAADFfsMkDOi6RJmdHfFRfNmxAAG\/fEFA\"","id":"AQMkADEwZjA1OGFkLTdiZmItNGVhZC1hZjU0LWNiN2E5N2Q3M2VhNwBGAAADKULPD_-h-UyldzHnJR6vNgcAxX7DJAzoukSZnR3xUXzZsQAAAgEOAAAAxX7DJAzoukSZnR3xUXzZsQABv5a9WwAAAA==","createdDateTime":"2020-02-12T16:12:44Z","lastModifiedDateTime":"2020-02-12T16:12:44Z","changeKey":"EQAAABYAAADFfsMkDOi6RJmdHfFRfNmxAAG\/fEFA","categories":[],"parentFolderId":"AQMkADEwZjA1OGFkLTdiZmItNGVhZC1hZjU0LWNiN2E5N2Q3M2VhNwAuAAADKULPD_-h-UyldzHnJR6vNgEAxX7DJAzoukSZnR3xUXzZsQAAAgEOAAAA","birthday":null,"fileAs":"","displayName":"jack Jia","givenName":"jack","initials":null,"middleName":null,"nickName":null,"surname":"Jia","title":null,"yomiGivenName":null,"yomiSurname":null,"yomiCompanyName":null,"generation":null,"imAddresses":[],"jobTitle":null,"companyName":null,"department":null,"officeLocation":null,"profession":null,"businessHomePage":null,"assistantName":null,"manager":null,"homePhones":[],"mobilePhone":null,"businessPhones":["businessPhones"],"spouseName":null,"personalNotes":"","children":[],"emailAddresses":[{"name":"Jack Jia","address":"jack@hanxia.onmicrosoft.com"}],"homeAddress":[],"businessAddress":[],"otherAddress":[]}

The createdDateTime and lastModifiedDateTime in the response:

    "createdDateTime": "2020-02-12T16:12:44Z"
    "lastModifiedDateTime": "2020-02-12T16:12:44Z"

And, with Microsoft Graph Explorer, I got the following result:

enter image description here

You can see that both createdDateTime and lastModifiedDateTime are consistent. Could you please have another try to see if it is just a temporary problem.

Jack Jia
  • 5,268
  • 1
  • 12
  • 14
  • Try again you will get to see difference.Some time lastModifiedDateTime are same but some time there is a difference of 1 or 2 sec – am.dev Feb 13 '20 at 11:44
  • @amitsuyala Could you please share some screenshots? – Jack Jia Feb 13 '20 at 12:23
  • Thanks for help brother.Now I am using sleep because it is taking some seconds to get saved in o 365 server – am.dev Feb 24 '20 at 11:51