カートを更新するUpdate a cart
適用対象Applies To
- パートナー センターPartner Center
カート内の顧客の注文を更新する方法。How to update an order for a customer in a cart.
前提条件Prerequisites
パートナー センターの認証に関するページで説明している資格情報。Credentials as described in Partner Center authentication. このシナリオでは、スタンドアロンアプリとアプリ + ユーザー資格情報の両方を使用した認証がサポートされています。This scenario supports authentication with both standalone App and App+User credentials.
顧客 ID です (
customer-tenant-id
)。A customer ID (customer-tenant-id
). お客様の ID がわからない場合は、パートナー センターのダッシュボードで検索できます。If you don't know the customer's ID, you can look it up in the Partner Center dashboard. パートナー センター メニューの [CSP] を選択し、 [顧客] を選択します。Select CSP from the Partner Center menu, followed by Customers. 顧客一覧からお客様を選び、 [アカウント] を選択します。Select the customer from the customer list, then select Account. お客様のアカウント ページで、 [顧客のアカウント情報] セクションの Microsoft ID を探します。On the customer’s Account page, look for the Microsoft ID in the Customer Account Info section. Microsoft ID は、顧客 ID (customer-tenant-id
) と同じです。The Microsoft ID is the same as the customer ID (customer-tenant-id
).既存のカートのカート ID。A Cart ID for an existing cart.
C#C#
顧客の注文を更新するには、 ById () 関数を使用して customer および cart ID を渡すことによって、 get () メソッドを使用してカートを取得します。To update an order for a customer, get the cart using the Get() method by passing the customer and cart ID's using the ById() function. カートに必要な変更を加えます。Make the necessary changes to the cart. 次に、 ById () メソッドを使用して、customer および cart ID を使用してPutメソッドを呼び出します。Now call the Put method by using customer and cart ID's using the ById() method.
最後に、 Put () メソッドまたはputasync () メソッドを呼び出して、注文を作成します。Finally, call the Put() or PutAsync() method to create the order.
IAggregatePartner partnerOperations;
string customerId;
string cartId;
var cart = partnerOperations.Customers.ById(customerId).Cart.ById(cartId).Get();
cart.LineItems.ToArray()[0].Quantity++;
var updatedCart = partnerOperations.Customers.ById(customerId).Cart.ById(cartId).Put(cart);
REST 要求REST request
要求の構文Request syntax
認証方法Method | 要求 URIRequest URI |
---|---|
PUTPUT | {baseURL}/v1/customers/{customer-id}/carts/{cart-id} HTTP/1.1{baseURL}/v1/customers/{customer-id}/carts/{cart-id} HTTP/1.1 |
URI パラメーターURI parameters
次のパスパラメーターを使用して顧客を特定し、更新するカートを指定します。Use the following path parameters to identify the customer, and specify the cart to be updated.
名前Name | TypeType | 必須Required | 説明Description |
---|---|---|---|
顧客 idcustomer-id | stringstring | はいYes | 顧客を識別する GUID 形式の顧客 id。A GUID formatted customer-id that identifies the customer. |
カート-idcart-id | stringstring | はいYes | カートを識別する GUID 形式のカート id。A GUID formatted cart-id that identifies the cart. |
要求ヘッダーRequest headers
詳細については、「パートナー センター REST ヘッダー」を参照してください。For more information, see Partner Center REST headers.
[要求本文]Request body
次の表では、要求本文に含まれるカートのプロパティについて説明します。This table describes the Cart properties in the request body.
プロパティProperty | TypeType | 必須Required | 説明Description |
---|---|---|---|
idid | stringstring | いいえNo | カートが正常に作成されたときに提供されるカート識別子。A cart identifier that is supplied upon successful creation of the cart. |
前のタイムスタンプcreationTimeStamp | DateTimeDateTime | いいえNo | カートが作成された日付 (日付/時刻形式)。The date the cart was created, in date-time format. カートが正常に作成されたときに適用されます。Applied upon successful creation of the cart. |
lastModifiedTimeStamplastModifiedTimeStamp | DateTimeDateTime | いいえNo | カートが最後に更新された日付 (日付/時刻形式)。The date the cart was last updated, in date-time format. カートが正常に作成されたときに適用されます。Applied upon successful creation of the cart. |
expirationTimeStampexpirationTimeStamp | DateTimeDateTime | いいえNo | カートの有効期限が切れる日付 (日付と時刻の形式)。The date the cart will expire, in date-time format. カートの作成が成功したときに適用されます。Applied upon successful creation of cart. |
lastModifiedUserlastModifiedUser | 文字列string | いいえNo | カートを最後に更新したユーザー。The user who last updated the cart. カートの作成が成功したときに適用されます。Applied upon successful creation of cart. |
lineItemslineItems | オブジェクトの配列Array of objects | はいYes | CartLineItemリソースの配列。An Array of CartLineItem resources. |
次の表では、要求本文のCartLineItemプロパティについて説明します。This table describes the CartLineItem properties in the request body.
プロパティProperty | TypeType | 必須Required | 説明Description |
---|---|---|---|
idid | stringstring | いいえNo | カートの品目の一意の識別子。A Unique identifier for a cart line item. カートの作成が成功したときに適用されます。Applied upon successful creation of cart. |
catalogIdcatalogId | stringstring | はいYes | カタログ項目の識別子。The catalog item identifier. |
friendlyNamefriendlyName | 文字列string | いいえNo | 省略可能。Optional. 明確に区別できるように、パートナーによって定義された項目のフレンドリ名。The friendly name for the item defined by the partner to help disambiguate. |
数量quantity | INTint | はいYes | ライセンスまたはインスタンスの数。The number of licenses or instances. |
currencyCodecurrencyCode | stringstring | いいえNo | 通貨コード。The currency code. |
billingCyclebillingCycle | ObjectObject | はいYes | 現在の期間に設定されている請求サイクルの種類。The type of billing cycle set for the current period. |
participantsparticipants | オブジェクトの文字列ペアの一覧List of Object String pairs | いいえNo | 購入の参加者のコレクション。A collection of participants on the purchase. |
provisioningContextprovisioningContext | Dictionary<string、string>Dictionary<string, string> | いいえNo | プランのプロビジョニングに使用されるコンテキスト。A context used for provisioning of offer. |
orderGrouporderGroup | stringstring | いいえNo | 一緒に配置できる項目を示すグループ。A group to indicate which items can be placed together. |
errorerror | ObjectObject | いいえNo | エラーが発生した場合にカートが作成された後に適用されます。Applied after cart is created in case of an error. |
要求の例Request example
PUT /v1/customers/d6bf25b7-e0a8-4f2d-a31b-97b55cfc774d/carts/65faf57b-0205-47ee-92b3-08dcf233ea73/ HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 4fa6dad6-a89f-4875-8247-8294a10ae1cf
MS-CorrelationId: 0e93c70c-977a-4a88-9580-7cf084c73286
X-Locale: en-US
MS-PartnerCenter-Client: Partner Center .NET SDK
Content-Type: application/json
Host: api.partnercenter.microsoft.com
Content-Length: 496
Expect: 100-continue
{
{
"Id":"b4c8fdea-cbe4-4d17-9576-13fcacbf9605",
"CreationTimestamp":"2018-03-15T17:15:02.3840528Z",
"LastModifiedTimestamp":"2018-03-15T17:15:02.3840528Z",
"ExpirationTimestamp":"0001-01-01T00:00:00",
"LastModifiedUser":"2713ccd7-ea3b-470a-9cfb-451d5d0482cc",
"LineItems":[
{
"Id":0,
"CatalogItemId":"DG7GMGF0DWTL:0001:DG7GMGF0DSJB",
"FriendlyName":"A_sample_Azure_RI",
"Quantity":2,
"BillingCycle":"one_time",
"ProvisioningContext": {
"SubscriptionId": "3D5ECED6-1151-44C7-AEE6-70A4BB725666",
"Scope": "shared",
"Duration": "1Year"
}
}
],
}
}
REST 応答REST response
成功した場合、このメソッドは、応答本文で設定されたカートリソースを返します。If successful, this method returns the populated Cart resource in the response body.
応答の成功とエラーのコードResponse success and error codes
各応答には、成功または失敗を示す HTTP ステータス コードと、追加のデバッグ情報が付属しています。Each response comes with an HTTP status code that indicates success or failure and additional debugging information. このコード、エラーの種類、追加のパラメーターを読み取るには、ネットワーク トレース ツールを使用します。Use a network trace tool to read this code, error type, and additional parameters. 完全な一覧については、エラー コードに関するページを参照してください。For the full list, see Error Codes.
応答の例Response example
HTTP/1.1 201 Created
Content-Length: 764
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 0e93c70c-977a-4a88-9580-7cf084c73286
MS-RequestId: 4fa6dad6-a89f-4875-8247-8294a10ae1cf
X-Locale: en-US,en-US
MS-CV: sF/wRa2ih0CzbABc.0
MS-ServerId: 000001
Date: Thu, 15 Mar 2018 17:15:01 GMT
{
"id": "b4c8fdea-cbe4-4d17-9576-13fcacbf9605",
"creationTimestamp": "2018-03-15T17:15:02.3840528Z",
"lastModifiedTimestamp": "2018-03-15T17:15:02.3840528Z",
"lastModifiedUser": "2713ccd7-ea3b-470a-9cfb-451d5d0482cc",
"lineItems": [
{
"id": 0,
"catalogItemId": "DG7GMGF0DWTL:0001:DG7GMGF0DSJB",
"friendlyName": "A_sample_Azure_RI",
"quantity": 2,
"currencyCode": "USD",
"billingCycle": "one_time",
"ProvisioningContext": {
"subscriptionId": "3D5ECED6-1151-44C7-AEE6-70A4BB725666",
"scope": "shared",
"duration": "1Year"
}
"orderGroup": "0"
}
],
"links": {
"self": {
"uri": "/v1/customers/d6bf25b7-e0a8-4f2d-a31b-97b55cfc774d/carts/b4c8fdea-cbe4-4d17-9576-13fcacbf9605/",
"method": "GET",
"headers": []
}
},
"attributes": {
"objectType": "Cart"
}
}