【问题标题】:o365 rest api contact, no property fax?o365 rest api 联系,没有物业传真?
【发布时间】:2016-03-17 05:47:44
【问题描述】:

我使用 API REST 在 O365 中导入了一些联系人。我的代码运行良好。我更新所有字段。但就我而言,要导入的最后一个字段是 BusinessFax 号码。我没有找到这个领域!在 O365 Web 应用程序或 Outlook 中,我会在一些字段中查找传真号码。但在 rest api o365 的文档中没有:https://msdn.microsoft.com/office/office365/api/complex-types-for-mail-contacts-calendar#RESTAPIResourcesContact

数据定义类型中没有:https://outlook.office.com/api/v2.0/$metadata

如果我在我的 Json 文件中测试一些属性:Fax、FaxNumber、BusinessFax、... 我收到错误 400,错误请求 :(

太棒了……那么,如何在联系人中导入传真号码???哈哈

妮可

【问题讨论】:

    标签: field contact fax outlook-restapi office365-restapi


    【解决方案1】:

    Office 365 REST API 尚不支持此属性。作为一种解决方法,我们可以通过 Exchange Web 服务获取此属性。以下是检索传真电话号码的代码示例供您参考:

    public static void Main(string[] args)
    {
        ExchangeService service = new ExchangeService();
    
        service.Credentials = new WebCredentials("{EmailAddress}", "{Password}");
    
        service.TraceEnabled = true;
        service.TraceFlags = TraceFlags.All;
    
        service.AutodiscoverUrl("{EmailAddress}", RedirectionUrlValidationCallback);
    
        Folder contacts = Folder.Bind(service, WellKnownFolderName.Contacts);
        SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(ContactSchema.GivenName, "user1"));
        ItemView view = new ItemView(1);
    
    
        FindItemsResults<Item> findResults =service.FindItems(WellKnownFolderName.Contacts,sf, view);
    
        foreach (Item item in findResults)
        {
            if (item is Contact)
            {
                Contact contact = item as Contact;
                Console.WriteLine(contact.PhoneNumbers[PhoneNumberKey.BusinessFax]);
            }
        }
    
    }
    
    
    private static bool RedirectionUrlValidationCallback(string redirectionUrl)
    {
        // The default for the validation callback is to reject the URL.
        bool result = false;
    
        Uri redirectionUri = new Uri(redirectionUrl);
    
        // Validate the contents of the redirection URL. In this simple validation
        // callback, the redirection URL is considered valid if it is using HTTPS
        // to encrypt the authentication credentials. 
        if (redirectionUri.Scheme == "https")
        {
            result = true;
        }
        return result;
    }
    

    您可以通过以下链接参考此属性:

    https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.contact_properties(v=exchg.80).aspx

    https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.contact.phonenumbers(v=exchg.80).aspx

    https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.phonenumberkey(v=exchg.80).aspx

    您可能还对使用 Exchange 网络服务进行身份验证感兴趣,以下是供您参考的链接:

    http://blogs.msdn.com/b/webdav_101/archive/2015/05/11/ews-authentication-issues.aspx

    【讨论】:

      【解决方案2】:

      Outlook REST API 现在支持 beta 端点中的扩展属性,您可以使用它来获取/设置未在项目的默认形状上返回的属性。如果您想获取带有 BusinessFax 值的联系人,只需执行 GET 即可:

      https://outlook.office.com/api/beta/Me/Contacts?$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String 0x3A24')
      

      (十六进制值是 MAPI 属性标记值。对于 BusinessFax,它是 0x3A24)您还可以使用 PATCH 更新给定联系人的商务传真号码。下面是 JSON 有效负载的样子:

      {
        "SingleValueExtendedProperties" : 
        [
          {
            "PropertyId" : "String 0x3A24",
            "Value" : "123-456-7890"
          }
        ]
      }
      

      同样,目前仅在 beta 端点中受支持,我们不建议将其用于任何生产代码,因为经常会发生重大更改。

      Reference For Extended Properties in REST

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-30
        • 2021-10-30
        • 2012-04-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多