无法使用 REST 从 Outlook 365 获取联系人备注 API

Cannot get Contact Notes from Outlook 365 using REST API

我一直在尝试将所有联系人从 Outlook 365 导入另一个数据库。我可以轻松获取所有姓名、电子邮件、地址等。

但是当我想获取位于 Outlook 365 联系人第二页上的便笺时,它们是空的。

我正在使用 PHP 代码,用 URL:

调用 API
https://outlook.office.com/api/v2.0/Me/Contacts 

没有特定参数。所有登录、令牌等部分都得到妥善处理并正常运行。

这是我当前通过 print_r 的通话收到的数组示例:

Array ( [Id] => ... [CreatedDateTime] => ... [LastModifiedDateTime] => ... [ChangeKey] => ... [Categories] => Array ( [0] => ... ) [ParentFolderId] => ... [Birthday] => [FileAs] => ... [DisplayName] => ... [GivenName] => ...[Initials] => [MiddleName] => [NickName] => ... [Surname] => ... [Title] => [YomiGivenName] => [YomiSurname] => [YomiCompanyName] => [Generation] => [EmailAddresses] => Array ( [0] => Array ( [Name] => ...[Address] => ...) ) [ImAddresses] => Array ( ) [JobTitle] => ... [CompanyName] => ... [Department] => [OfficeLocation] => ...[Profession] => [BusinessHomePage] => ... [AssistantName] => [Manager] => [HomePhones] => Array ( ) [MobilePhone1] => ... [BusinessPhones] => Array ( [0] => ... ) [HomeAddress] => Array ( ) [BusinessAddress] => Array ( [Street] => ... [City] => ...[State] => ...[CountryOrRegion] => ...[PostalCode] => ...) [OtherAddress] => Array ( ) [SpouseName] => [PersonalNotes] => [Children] => Array ( ) )

`PersonalNotes' 每次都是空的,即使联系人中的注释包含大量文本。

进行 API 调用的函数是这个函数:

public function makeApiCall($method, $url, $payload = NULL) {
  // Generate the list of headers to always send.
  $headers = array(
    "User-Agent: outlook/1.0",         // Sending a User-Agent header is a best practice.
    "Authorization: Bearer ".$this->access_token, // Always need our auth token!
    "Accept: text/*, application/xml, application/json; odata.metadata=none",             // Always accept JSON response.
    "client-request-id: ".self::makeGuid(), // Stamp each new request with a new GUID.
    "return-client-request-id: true",       // Tell the server to include our request-id GUID in the response.
    "X-AnchorMailbox: ".$this->user_email         // Provider user's email to optimize routing of API call
  );
  // print_r($headers);
  $curl = curl_init();

  switch(strtoupper($method)) {
    case "GET":
      error_log("Doing GET");
      break;
    case "POST": // PAYLOAD POUR POST DOIT ETRE json_encode!!!
      error_log("Doing POST");
      $headers[] = "Content-Type: application/json";
      curl_setopt($curl, CURLOPT_POST, true);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
      break;
    case "PATCH":
      error_log("Doing PATCH");
      $headers[] = "Content-Type: application/json";
      curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
      curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
      break;
    case "DELETE":
      error_log("Doing DELETE");
      curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
      break;
    default:
      error_log("INVALID METHOD: ".$method);
      exit;
  }

  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  $response = curl_exec($curl);
  error_log("curl_exec done.");

    $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  if ($httpCode >= 400) {
    return array('errorNumber' => $httpCode,
                 'error' => 'Request returned HTTP error '.$httpCode);
  }

  $curl_errno = curl_errno($curl);
  $curl_err = curl_error($curl);

  if ($curl_errno) {
    $msg = $curl_errno.": ".$curl_err;
    error_log("CURL returned an error: ".$msg);
    curl_close($curl);
    return array('errorNumber' => $curl_errno,
                 'error' => $msg);
  }
  else {
    error_log("Response: ".$response);
    curl_close($curl);
    return json_decode($response, true);
  }
}

任何帮助将不胜感激,谢谢!

有意思。我也看到了这一点,但前提是我在桌面版 Outlook 中设置了注释。如果我在 Outlook Web App 中设置它,它工作正常。我什至可以在 OWA 中编辑 'broken' 并修复它。

所以作为临时答案,您可以在 OWA 中编辑联系人来修复它们。一旦我有更好的答案,我会更新这个答案。