다음을 통해 공유


ID로 구독 업데이트

적용 대상: 파트너 센터 | 21Vianet에서 운영되는 파트너 센터 | Microsoft Cloud for US Government 파트너 센터

ID별 구독 업데이트

파트너 센터에서 먼저 고객을 선택하여 이 작업을 수행합니다. 그런 다음 업데이트하려는 해당 구독을 선택합니다. 완료하려면 원하는 값을 변경한 다음 제출을 선택합니다 .

필수 조건

  • 자격 증명(파트너 센터 인증에서 설명). 이 시나리오는 독립 실행형 앱 및 App+사용자 자격 증명을 모두 사용하여 인증을 지원합니다.

  • 고객 ID (customer-tenant-id). 고객의 ID를 모르는 경우 고객 작업 영역, 고객 목록에서 고객, 계정을 선택하여파트너 센터에서 조회할 수 있습니다. 고객 계정 페이지의 고객 계정 정보 섹션에서 Microsoft ID를 찾습니다. Microsoft ID는 고객 ID(customer-tenant-id)와 동일합니다.

  • 구독 ID입니다.

C#

고객의 구독 값을 업데이트하려면 먼저 구독을 가져와서 구독의 원하는 속성을 변경합니다. 변경이 완료되면 IAggregatePartner.Customers 컬렉션을 사용하고 ById() 메서드를 호출합니다. 그런 다음, Subscriptions 속성과 ById() 메서드를 호출합니다. 그런 다음 Patch() 메서드를 호출하여 마칩니다.

// IAggregatePartner partnerOperations;
// var customerId;
// var subscriptionId;

//retrieving the subscription, for the purpose of the sample
ResourceCollection<Subscription> customerSubscriptions = partnerOperations.Customers.ById(selectedCustomerId).Subscriptions.Get();
Subscription selectedSubscription = customerSubscriptions.Items.FirstOrDefault(sub => sub.Status == SubscriptionStatus.Active);

//update selected subscription; a variety of fields can be updated, but quantity is used as an example below
selectedSubscription.Quantity++;

var updatedSubscription = partnerOperations.Customers.ById(selectedCustomerId).Subscriptions.ById(selectedSubscription.Id).Patch(selectedSubscription);

샘플: 콘솔 테스트 앱. 프로젝트: PartnerSDK.FeatureSample 클래스: UpdateSubscription.cs

REST 요청

요청 구문

메서드 요청 URI
패치 {baseURL}/v1/customers/{customer-tenant-id}/subscriptions/{subscription-id} HTTP/1.1

URI 매개 변수

이 표에는 구독을 업데이트하는 데 필요한 쿼리 매개 변수가 나열됩니다.

이름 Type 필수 설명
customer-tenant-id guid Y 고객에게 해당하는 GUID입니다.
subscription-id guid Y 구독에 해당하는 GUID입니다.

요청 헤더

자세한 내용은 파트너 센터 REST 헤더를 참조하세요.

요청 본문

요청 본문에는 전체 구독 리소스가 필요합니다. 원하는 속성이 업데이트되었는지 확인합니다.

구독의 autoRenewEnabled가 true로 설정되거나, 다음 용어 지침이 있거나, 다음 청구 지침이 있는 경우 이러한 이러한 특성은 PATCH 요청에 대한 본문의 일부로 필요합니다. 이러한 특성이 제공되지 않으면 autoRenewEnabled가 실수로 false로 설정되거나 다음 용어/청구 지침이 삭제됩니다. 이는 최소 정보가 페이로드에 있는 경우에만 적용됩니다. Get 호출이 이전에 수행되고 응답이 수정되어 API에 전달되면 필요한 필드가 요청에 채워집니다.

요청 예제

PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/subscriptions/<id-for-subscription> HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: ca7c39f7-1a80-43bc-90d8-ee7d1cad3831
MS-CorrelationId: ec8f62e5-1d92-47e9-8d5d-1924af105f2c
Content-Type: application/json
Content-Length: 1029
Expect: 100-continue
Connection: Keep-Alive

{
    "Id": "83ef9d05-4169-4ef9-9657-0e86b1eab1de",
    "FriendlyName": "nickname",
    "Quantity": 2,
    "UnitType": "none",
    "ParentSubscriptionId": null,
    "CreationDate": "2015-11-25T06:41:12Z",
    "EffectiveStartDate": "2015-11-24T08:00:00Z",
    "CommitmentEndDate": "2016-12-12T08:00:00Z",
    "Status": "active",
    "AutoRenewEnabled": false,
    "BillingType": "none",
    "PartnerId": null,
    "ContractType": "subscription",
    "OrderId": "6183db3d-6318-4e52-877e-25806e4971be",
    "Attributes": {
        "Etag": "<etag>",
        "ObjectType": "Subscription"
    }
}

새 상거래 구독에 대한 요청 예제로 친숙한 이름을 업데이트합니다.

라이선스 기반 서비스에 대한 새로운 상거래 환경에는 많은 새로운 기능이 포함되며 모든 클라우드 솔루션 공급자 파트너(CSP)에서 사용할 수 있습니다. 자세한 내용은 새 상거래 환경 개요를 참조하세요.

PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/subscriptions/<subscription-id> HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: ca7c39f7-1a80-43bc-90d8-ee7d1cad3831
MS-CorrelationId: ec8f62e5-1d92-47e9-8d5d-1924af105f2c
Content-Type: application/json
Content-Length: 1029
Expect: 100-continue
Connection: Keep-Alive

{
    "id": "a4c1340d-6911-4758-bba3-0c4c6007d161",
    "offerId": "CFQ7TTC0LH18:0001:CFQ7TTC0K971",
    "offerName": "Microsoft 365 Business Basic",
    "friendlyName": "nickname", //originally Microsoft 365 Business Basic
    "productType": {
        "id": "OnlineServicesNCE",
        "displayName": "OnlineServicesNCE"
    },
    "quantity": 1,
    "unitType": "Licenses",
    "hasPurchasableAddons": false,
    "creationDate": "2021-01-14T16:57:15.0966728Z",
    "effectiveStartDate": "2021-01-14T16:57:14.498252Z",
    "commitmentEndDate": "2022-01-13T00:00:00Z",
    "status": "active", 
    "autoRenewEnabled": true, //must be included if set to true; see note in Request Body section
    "isTrial": false,
    "billingType": "license",
    "billingCycle": "monthly",
    "termDuration": "P1Y",
    "renewalTermDuration": "",
    "refundOptions": [
        {
            "type": "Full",
            "expiresAt": "2021-01-15T00:00:00Z"
        }
    ],
    "isMicrosoftProduct": true,
    "partnerId": "",
    "attentionNeeded": false,
    "actionTaken": false,
    "contractType": "subscription",
    "links": {
        "product": {
            "uri": "/products/CFQ7TTC0LH18?country=US",
            "method": "GET",
            "headers": []
        },
        "sku": {
            "uri": "/products/CFQ7TTC0LH18/skus/0001?country=US",
            "method": "GET",
            "headers": []
        },
        "availability": {
            "uri": "/products/CFQ7TTC0LH18/skus/0001/availabilities/CFQ7TTC0K971?country=US",
            "method": "GET",
            "headers": []
        },
        "self": {
            "uri": "/customers/d8202a51-69f9-4228-b900-d0e081af17d7/subscriptions/a4c1340d-6911-4758-bba3-0c4c6007d161",
            "method": "GET",
            "headers": []
        }
    },
    "publisherName": "Microsoft Corporation",
    "orderId": "34b37d7340cc",
    "attributes": {
        "objectType": "Subscription"
    }
}

REST 응답

성공하면 이 메서드는 응답 본문에서 HTTP 상태 200 상태 코드 및 업데이트된 구독 리소스 속성을 반환합니다.

응답 성공 및 오류 코드

각 응답은 성공 또는 실패 및 기타 디버깅 정보를 나타내는 HTTP 상태 코드를 반환합니다. 네트워크 추적 도구를 사용하여 상태 코드, 오류 유형 및 기타 매개 변수를 읽습니다. 전체 목록은 오류 코드를 참조하세요.

패치 작업이 예상 시간보다 오래 걸리면 파트너 센터는 HTTP 상태 202 상태 코드와 구독을 검색할 위치를 가리키는 위치 헤더를 보냅니다. 구독을 주기적으로 쿼리하여 상태 모니터링할 수 있습니다.

응답 예제

응답 예제 #1

HTTP 상태 200 상태 코드로 성공한 요청:

PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/subscriptions/<subscriptionID> HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-Contract-Version: v1
MS-RequestId: ca7c39f7-1a80-43bc-90d8-ee7d1cad3831
MS-CorrelationId: ec8f62e5-1d92-47e9-8d5d-1924af105f2c
Content-Type: application/json
Content-Length: 1029
Expect: 100-continue
Connection: Keep-Alive

{
    "Id": "83ef9d05-4169-4ef9-9657-0e86b1eab1de",
    "FriendlyName": "nickname",
    "Quantity": 1,
    "UnitType": "none",
    "ParentSubscriptionId": null,
    "CreationDate": "2015-11-25T06:41:12Z",
    "EffectiveStartDate": "2015-11-24T08:00:00Z",
    "CommitmentEndDate": "2016-12-12T08:00:00Z",
    "Status": "active",
    "AutoRenewEnabled": true,
    "BillingType": "none",
    "PartnerId": null,
    "ContractType": "subscription",
    "Links": {
        "Offer": {
            "Uri": "/v1/offers/0CCA44D6-68E9-4762-94EE-31ECE98783B9",
            "Method": "GET",
            "Headers": []
        },
        "Entitlement": {
            "Uri": "/entitlements?key=<key>",
            "Method": "GET",
            "Headers": []
        },
        "Self": {
            "Uri": "/subscriptions?key=<key>",
            "Method": "GET",
            "Headers": []
        }
    },
    "OrderId": "6183db3d-6318-4e52-877e-25806e4971be",
    "Attributes": {
        "Etag": "<etag>",
        "ObjectType": "Subscription"
    }
}

응답 예제 #2

HTTP 상태 202 상태 코드로 성공한 요청:

PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/subscriptions/<subscriptionID> HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 01880c1b-1966-40f0-d470-501a66d9948b
MS-CorrelationId: 2c5827c1-d5f9-4835-cc6d-f1918b782c79
Content-Type: application/json
Content-Length: 1432
Connection: Keep-Alive
Location: /customers/<customer-tenant-id>/subscriptions/<subscriptionID>