获取客户的公司简介

适用于:合作伙伴中心 | 由世纪互联运营的合作伙伴中心 | Microsoft Cloud for US Government 合作伙伴中心

获取客户的公司配置文件。

先决条件

  • 合作伙伴中心身份验证中所述的凭据。 此方案只支持使用应用凭据和用户凭据进行身份验证。

  • 客户 ID (customer-tenant-id)。 如果不知道客户的 ID,可以在合作伙伴中心查找它。 从合作伙伴中心主页中选择“客户”工作区。 从 “客户”列表中选择客户,然后选择“ 帐户”。 在客户的“帐户”页上,在“客户帐户详细信息”部分查找 Microsoft ID。 Microsoft ID 与客户 ID (customer-tenant-id) 相同。

重要

如果合作伙伴在客户租户上没有 DAP 访问权限,则“获取客户公司配置文件 API”调用将不会返回响应中的以下属性。 否则,它将返回响应示例中列出的所有属性。

  • CompanyProfileAddress
  • CompanyProfileEmail
  • 自定义域

C#

若要获取客户的公司配置文件,请调用 IAggregatePartner.Customers.ById 方法并使用客户 ID 来标识客户。 然后从 Profiles 属性获取客户的 ICustomerProfileCollection 接口,以便访问其公司属性。 接下来,从 ICustomerProfileCollection.Company 属性获取 ICustomerReadonlyProfile 接口,并调用其 Get()GetAsync() 方法。

// IAggregatePartner partnerOperations;
// string customerId;

var companyProfile = partnerOperations.Customers.ById(customerId).Profiles.Company.Get();

示例下载合作伙伴中心 SDK项目:PartnerSdk.FeatureSamples :GetCustomerCompanyProfile.cs

Java

合作伙伴中心 Java SDK 可用于管理合作伙伴中心资源。 它是由合作伙伴社区维护的开源项目,不受 Microsoft 正式支持。 如果遇到问题,可以从社区获取帮助在 GitHub 上创建问题

若要获取客户的公司配置文件,请使用客户标识符调用 IAggregatePartner.getCustomers()。byId 函数来标识客户。 然后从 [getProfiles] 函数获取客户的 ICustomerProfileCollection 接口,以便访问其 Company 属性。 接下来,从 ICustomerProfileCollection.getCompany 函数获取 ICustomerReadonlyProfile 接口,并调用 get 函数。

// IAggregatePartner partnerOperations;
// String customerId;

CustomerCompanyProfile companyProfile = partnerOperations.getCustomers().byId(customerId).getProfiles().getCompany().get();

REST 请求

请求语法

方法 请求 URI
GET {baseURL}/v1/customers/{customer-tenant-id}/profiles/company HTTP/1.1

URI 参数

使用以下查询参数获取公司配置文件。

名称 Type 需要 说明
customer-tenant-id guid Y 该值是 GUID 格式 的客户租户 ID ,允许经销商筛选属于经销商的给定客户的结果。

请求标头

有关详细信息,请参阅合作伙伴中心 REST 标头

请求正文

请求示例

GET https://api.partnercenter.microsoft.com/v1/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/profiles/company HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 0b6f039c-e4b5-4b9e-bdac-b39077bb60da
MS-CorrelationId: ffa9174c-dbcb-47de-b70d-10e640a7f1b4
X-Locale: en-US
Host: api.partnercenter.microsoft.com
Connection: Keep-Alive

REST 响应

如果成功,此方法在响应正文中返回信息。

响应的成功和错误代码

每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 有关完整列表,请参阅 合作伙伴中心 REST 错误代码

响应示例

HTTP/1.1 200 OK
Content-Length: 488
Content-Type: application/json; charset=utf-8
MS-CorrelationId: ffa9174c-dbcb-47de-b70d-10e640a7f1b4
MS-RequestId: 0b6f039c-e4b5-4b9e-bdac-b39077bb60da
MS-CV: /e74N8OrkE29ycwZ.0
MS-ServerId: 101112202
Date: Wed, 04 Jan 2017 19:48:51 GMT

{
    "tenantId": "4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04",
    "domain": "dtdemocspcustomer005.onmicrosoft.com",
    "companyName": "DT Demo CSP Customer 005",
    "address": {
        "country": "US",
        "region": "WA",
        "city": "Redmond ",
        "addressLine1": "1 Microsoft Way",
        "postalCode": "98052",
        "phoneNumber": "4155551212"
    },
    "email": "daniel@hotmail.com.tw",
    "links": {
        "self": {
            "uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/profiles/company",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "CustomerCompanyProfile"
    }
}