使用合作夥伴中心 API 確認客戶接受Microsoft客戶合約
適用對象為:合作夥伴中心
不適用於:由 21Vianet 營運的合作夥伴中心 |美國政府Microsoft雲端合作夥伴中心
合作夥伴中心目前僅支援在Microsoft公用雲端中確認客戶接受Microsoft客戶合約。
本文說明如何確認或重新確認客戶接受Microsoft客戶合約。
先決條件
- 如果您使用合作夥伴中心 .NET SDK,則需要 1.14 版或更新版本。
重要
自 2023 年 6 月起,最新的合作夥伴中心 .NET SDK 3.4.0 版現已封存。 您可以從 GitHub下載 SDK 版本,以及包含實用資訊的 自述檔。
鼓勵合作夥伴繼續使用 合作夥伴中心 REST API。
認證如合作夥伴中心驗證中所述。 此案例僅支援 App+用戶驗證。
客戶標識碼 (
customer-tenant-id
)。 如果您不知道客戶的標識碼,可以在 合作夥伴中心 中選擇 [客戶 工作區],然後從客戶清單中選擇客戶,接著選擇 帳戶。 在客戶的 [帳戶] 頁面上,於 [客戶帳戶資訊] 區段中尋找 Microsoft ID。 Microsoft識別碼與客戶標識碼 (customer-tenant-id
) 相同。客戶接受Microsoft客戶合約時的日期(dateAgreed]。
接受 Microsoft 客戶合約的客戶組織之用戶資訊。 這包括:
- 名字
- 姓
- 電子郵件位址
- 電話號碼(選擇性)
如果客戶有下列值變更,合作夥伴中心將允許為該客戶建立另一個合約:名字姓氏電子郵件地址電話號碼;否則合作夥伴會收到下列錯誤碼,因為建立重複的客戶
{
"code": 600061,
"message": "A partner confirmed agreement already exists for the customer.",
"description": "A partner confirmed agreement already exists for the customer.",
"errorName": "PartnerConfirmedAgreementAlreadyExists",
"isRetryable": false,
"parameters": {},
"errorMessageExtended": "InternalErrorCode=600061"
}
.NET
若要確認或重新確認客戶接受Microsoft客戶合約:
擷取Microsoft客戶合約的合約元數據。 您必須取得 Microsoft 客戶合約的 templateId。 如需詳細資訊,請參閱 取得 Microsoft 客戶合約的合約元資料。
// IAggregatePartner partnerOperations; string agreementType = "MicrosoftCustomerAgreement"; var microsoftCustomerAgreementDetails = partnerOperations.AgreementDetails.ByAgreementType(agreementType).Get().Items.Single();
建立新的 合約 物件,其中包含確認的詳細數據。
使用 IAggregatePartner.Customers 集合,並使用指定的 customer-tenant-id呼叫 ById 方法。
使用 合約 屬性,然後呼叫 Create 或 CreateAsync。
// string selectedCustomerId; var agreementToCreate = new Agreement { DateAgreed = DateTime.UtcNow, TemplateId = microsoftCustomerAgreementDetails.TemplateId, PrimaryContact = new Contact { FirstName = "Tania", LastName = "Carr", Email = "someone@example.com", PhoneNumber = "1234567890" } }; Agreement agreement = partnerOperations.Customers.ById(selectedCustomerId).Agreements.Create(agreementToCreate);
您可以從 控制台測試應用程式 專案中,找到 CreateCustomerAgreement 類別的完整範例。
REST 要求
若要確認或重新確認客戶接受Microsoft客戶合約:
- 擷取Microsoft客戶合約的合約元數據。 您必須取得Microsoft的客戶合約的templateId。 如需詳細資訊,請參閱 取得 Microsoft 客戶合約的合約元資料。
- 建立新的 合約 資源,以確認客戶已接受Microsoft客戶合約。 請使用下列 REST 要求語法。
要求語法
方法 | 要求 URI |
---|---|
貼文 | {baseURL}/v1/customers/{customer-tenant-id}/agreements HTTP/1.1 |
URI 參數
使用下列查詢參數來指定您正在確認的客戶。
名字 | 類型 | 必填 | 描述 |
---|---|---|---|
顧客租戶識別碼 | 全球唯一識別碼(GUID) | 是的 | 此值是以 GUID 格式 customer-tenant-id,這是可讓您指定客戶的識別碼。 |
請求標頭
如需詳細資訊,請參閱 合作夥伴中心 REST 標頭。
請求主體
下表描述 REST 要求主體中的必要屬性。
名字 | 類型 | 描述 |
---|---|---|
協定 | 物件 | 合作夥伴提供的詳細數據,以確認客戶接受Microsoft客戶合約。 |
協定
下表描述建立 合約 資源的最低必要字段。
財產 | 類型 | 描述 |
---|---|---|
主要聯絡人 | 聯繫人 | 客戶組織接受Microsoft客戶合約的使用者相關信息,包括:firstName、lastName、電子郵件,以及 phoneNumber (選擇性) |
同意日期 | UTC 日期時間格式的字串 | 客戶接受合約的日期。 |
樣板ID | 字串 | 客戶接受之合約類型的唯一標識碼。 您可以透過擷取Microsoft客戶合約的合約元數據來取得Microsoft客戶合約的 templateId。 如需詳細資訊,請參閱 取得Microsoft客戶合約 合約元數據。 |
類型 | 字串 | 客戶接受的合約類型。 如果客戶已接受Microsoft客戶合約,請使用 「MicrosoftCustomerAgreement」。。 |
要求範例
POST https://api.partnercenter.microsoft.com/v1/customers/14876998-c0dc-46e6-9d0c-65a57a6c32ec/agreements HTTP/1.1
Authorization: Bearer <token>
Content-Type: application/json
MS-RequestId: 94e4e214-6b06-4fb7-96d1-94d559f9b47f
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
{
"primaryContact": {
"firstName": "Tania",
"lastName": "Carr",
"email": "someone@example.com",
"phoneNumber": "1234567890"
},
"templateId": "aaaabbbb-0000-cccc-1111-dddd2222eeee",
"dateAgreed": "2018-06-14T00:00:00.000Z",
"type": "MicrosoftCustomerAgreement"
}
REST 回應
如果成功,該方法將返回 合約 資源。
回應成功和錯誤碼
每個回應都有一個 HTTP 狀態代碼,指出成功或失敗和其他偵錯資訊。
使用網路追蹤工具來讀取此程式代碼、錯誤類型和其他參數。 如需完整清單,請參閱 合作夥伴中心 REST 錯誤碼。
回應範例
HTTP/1.1 201 Created
Content-Length: 261
Content-Type: application/json
MS-RequestId: 94e4e214-6b06-4fb7-96d1-94d559f9b47f
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
{
"userId": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
"primaryContact": {
"firstName": "Tania",
"lastName": "Carr",
"email": "someone@example.com",
"phoneNumber": "1234567890"
},
"templateId": "aaaabbbb-0000-cccc-1111-dddd2222eeee",
"dateAgreed": "2018-06-14T00:00:00.000Z",
"type": "MicrosoftCustomerAgreement"
}