title: Why i am getting empty array in Users.history:list API
body: <p>I am trying to get history of changes done in gmail account using <code>Users:History</code> API with historyId. But somehow it is returns data after some seconds or minutes of changes done.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>function listHistory($service, $userId, $startHistoryId) {
    $opt_param = array('startHistoryId' =&gt; $startHistoryId);
    $pageToken = NULL;
    $histories = array();
  
    do {
      try {
        if ($pageToken) {
          $opt_param['pageToken'] = $pageToken;
        }
        $historyResponse = $service-&gt;users_history-&gt;listUsersHistory($userId, $opt_param);
        if ($historyResponse-&gt;getHistory()) {
          $histories = array_merge($histories, $historyResponse-&gt;getHistory());
          $pageToken = $historyResponse-&gt;getNextPageToken();
        }
      } catch (Exception $e) {
        print 'An error occurred: ' . $e-&gt;getMessage();
      }
    } while ($pageToken);
  
  
    return $histories;
  }
  </code></pre>
  
  <p>Ref: <a href="https://developers.google.com/gmail/api/v1/reference/users/history/list" rel="nofollow noreferrer">https://developers.google.com/gmail/api/v1/reference/users/history/list</a></p>