Freigeben über


Aktualisieren eines Abonnements nach ID

Gilt für: Partner Center | Partner Center-Betrieb durch 21Vianet | Partner Center für Microsoft Cloud for US Government

Aktualisiert ein Abonnement nach ID.

Führen Sie in Partner Center diesen Vorgang aus, indem Sie zuerst einen Kunden auswählen. Wählen Sie dann das betreffende Abonnement aus, das Sie aktualisieren möchten. Um den Vorgang abzuschließen, ändern Sie die gewünschten Werte, und wählen Sie dann "Absenden" aus .

Voraussetzungen

  • Anmeldeinformationen, wie unter Partner Center-Authentifizierung beschrieben. Dieses Szenario unterstützt die Authentifizierung mit eigenständigen App- und App+Benutzeranmeldeinformationen.

  • Eine Kunden-ID (customer-tenant-id). Wenn Sie die KUNDEN-ID nicht kennen, können Sie sie im Partner Center nachschlagen, indem Sie den Arbeitsbereich "Kunden " und dann den Kunden aus der Kundenliste und dann "Konto" auswählen. Suchen Sie auf der Kontoseite des Kunden im Abschnitt Kundenkontoinfo nach der Microsoft-ID. Die Microsoft-ID entspricht der Kunden-ID (customer-tenant-id).

  • Eine Abonnement-ID.

C#

Um werte des Abonnements eines Kunden zu aktualisieren, rufen Sie zuerst das Abonnement ab, und ändern Sie dann die gewünschten Eigenschaften des Abonnements. Nachdem die Änderung vorgenommen wurde, verwenden Sie Ihre IAggregatePartner.Customers-Auflistung , und rufen Sie die ById()- Methode auf. Rufen Sie dann die Subscriptions-Eigenschaft auf, gefolgt von der ById()-Methode. Rufen Sie dann die Patch() -Methode auf.

// 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);

Beispiel: Konsolentest-App. Projekt: PartnerSDK.FeatureSample-Klasse: UpdateSubscription.cs

REST-Anforderung

Anforderungssyntax

Methode Anforderungs-URI
PATCH {baseURL}/v1/customers/{customer-tenant-id}/subscriptions/{subscription-id} HTTP/1.1

URI-Parameter

In dieser Tabelle sind die erforderlichen Abfrageparameter aufgeführt, um das Abonnement zu aktualisieren.

Name Type Erforderlich Beschreibung
customer-tenant-id guid Y Eine GUID, die dem Kunden entspricht.
Abonnement-ID guid Y Eine GUID, die dem Abonnement entspricht.

Anforderungsheader

Weitere Informationen finden Sie unter Partner Center-REST-Header.

Anforderungstext

Im Anforderungstext ist eine vollständige Subscription-Ressource erforderlich. Stellen Sie sicher, dass die gewünschten Eigenschaften aktualisiert werden.

Wenn das autoRenewEnabled-Element eines Abonnements auf "true" festgelegt ist, nächste Ausdrucksanweisungen enthält oder über nächste Abrechnungsanweisungen verfügt, sind diese Attribute als Teil des Texts für die PATCH-Anforderung erforderlich. Wenn diese Attribute nicht bereitgestellt werden, wird autoRenewEnabled versehentlich auf "false" festgelegt, oder die nächsten Ausdrucks-/Abrechnungsanweisungen werden gelöscht. Dies gilt nur, wenn sich minimale Informationen in der Nutzlast befinden. Wenn ein Get-Aufruf vor und besagte Antwort geändert und an die API übergeben wird, werden die erforderlichen Felder in der Anforderung ausgefüllt.

Anforderungsbeispiel #1a

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"
    }
}

Anforderungsbeispiel #1b: Neues Commerce-Abonnement zum Aktualisieren des Anzeigenamens

Die neuen Commerce-Erfahrungen für lizenzbasierte Dienste umfassen viele neue Funktionen und sind für alle Cloud Solution Provider-Partner (CSPs) verfügbar. Weitere Informationen finden Sie unter Übersicht über neue Commerce-Erfahrungen.

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-Antwort

Wenn die Methode erfolgreich verläuft, werden der HTTP-Statuscode 200 und die aktualisierten Abonnementressourceneigenschaften im Antworttext zurückgegeben.

Erfolgs- und Fehlercodes der Antwort

Jede Antwort gibt einen HTTP-Statuscode zurück, der Erfolg oder Fehler und andere Debuginformationen angibt. Verwenden Sie ein Netzwerkablaufverfolgungstool, um den Statuscode, den Fehlertyp und andere Parameter zu lesen. Die vollständige Liste findest du unter Partner-API: REST-Fehlercodes.

Wenn der Patchvorgang länger als die erwartete Zeit dauert, sendet das Partner Center einen HTTP-Statuscode 202 und einen Ortsheader, der auf den Ort zeigt, an dem das Abonnement abgerufen werden soll. Sie können das Abonnement regelmäßig abfragen, um den Status zu überwachen.

Beispielantworten

Antwortbeispiel #1a

Erfolgreiche Anforderung mit einem HTTP-Statuscode 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"
    }
}

Antwortbeispiel #1b: Neues Commerce-Abonnement zum Aktualisieren des Anzeigenamens

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",  
    "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, 
    "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" 
    } 
}

Antwortbeispiel Nr. 2

Erfolgreiche Anforderung mit einem HTTP-Statuscode 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>