VIA-Connect - REST API » EntitySets » ProductVariations » ProductVariations-Examples

ProductVariations-Examples

Zuletzt geändert von Thomas Hoffmann am 2014/08/25 10:17
Kommentare (0) · Anhänge (0) · Historie

Variante erstellen

Im unteren Beispiel werden die Grunddaten für ein T-Shirt mit folgenden Variantenausprägungen erstellt.

Die Variantenausprägungen (z.B. Farbe, Grösse usw.) werden im EntitySet ProductVariationSpecifics definiert.

FarbeGrössePreisMengeSku
RotS17,9917T-Shirt-Rot-S

Ein komplexeres Beispiel finden Sie hier

Request


POST                    http://sandboxapi.via.de/publicapi/v1/api.svc/ProductVariations

Request HTTP-Header


Content-Type:           application/atom+xml
SubscriptionToken:      g93af799-6ae8-e111-8406-0050568261dc
Cookie:                 .ASPXAUTH=0186587E1743637D35632A7EDAF4F07EA67C6E4577770C3778FD9C17904A9D85B01369A8198B23A9AF530DBE93A68687C219BE1876B16B 0DAEBBD2C3318CA6C99D9C53E5B9FE17B7CF9661C5CDDDB97B90D5D3AF550100227EC8D6E6858FAE986AF2302C337B8DFEC6099898C19AA335A81317AB2B382DE72586AA9DF830C715332215AEBFD5E2FBA45F2BB5A7CA9793; path=/; HttpOnly

Request Body

In diesem Beispiel werden die Grunddaten für die Variante angelegt:

  • ProductId
  • Price
  • StockAmount
  • Sku

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="http://sandboxapi.via.de/publicapi/v1/api.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
 <content type="application/xml">
   <m:properties>
     <d:ProductId>1</d:ProductId>
     <d:Price>17.99</d:Price>
     <d:StockAmount>17</d:StockAmount>
     <d:Sku>T-Shirt-Rot-S</d:Sku>
   </m:properties>
 </content>
</entry>

Response

Response HTTP-Header


Status Code:            201 Created
Cache-Control:          no-cache
Content-Length:         2154
Content-Type:           application/atom+xml;charset=utf-8
DataServiceVersion:     1.0;
...

Response Body


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="http://sandboxapi.via.de/PublicApi/v1/Api.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
 <id>http://sandboxapi.via.de/PublicApi/v1/Api.svc/ProductVariations(1L)</id>
 <title type="text"></title>
 <updated>2012-11-22T13:14:36Z</updated>
 <author>
   <name />
 </author>
 <link rel="edit" title="ProductVariation" href="ProductVariations(1L)" />
 <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Product" type="application/atom+xml;type=entry" title="Product" href="ProductVariations(1L)/Product" />
 <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ProductVariationSpecifics" type="application/atom+xml;type=feed" title="ProductVariationSpecifics" href="ProductVariations(1L)/ProductVariationSpecifics" />
 <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ListingItems" type="application/atom+xml;type=feed" title="ListingItems" href="ProductVariations(1L)/ListingItems" />
 <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/SalesOrderItems" type="application/atom+xml;type=feed" title="SalesOrderItems" href="ProductVariations(1L)/SalesOrderItems" />
 <category term="Via.BlackBox.Entities.Api.ProductVariation" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
 <content type="application/xml">
   <m:properties>
     <d:Id m:type="Edm.Int64">1</d:Id>
     <d:ProductId m:type="Edm.Int64">1</d:ProductId>
     <d:Price m:type="Edm.Decimal">17.99</d:Price>
     <d:StockAmount m:type="Edm.Int32">17</d:StockAmount>
     <d:Sku>T-Shirt-Rot-S</d:Sku>
   </m:properties>
 </content>
</entry>

Request HTTP-Header


Content-Type:           application/json
Accept:                 application/json
SubscriptionToken:      g93af799-6ae8-e111-8406-0050568261dc
Cookie:                 .ASPXAUTH=0186587E1743637D35632A7EDAF4F07EA67C6E4577770C3778FD9C17904A9D85B01369A8198B23A9AF530DBE93A68687C219BE1876B16B 0DAEBBD2C3318CA6C99D9C53E5B9FE17B7CF9661C5CDDDB97B90D5D3AF550100227EC8D6E6858FAE986AF2302C337B8DFEC6099898C19AA335A81317AB2B382DE72586AA9DF830C715332215AEBFD5E2FBA45F2BB5A7CA9793; path=/; HttpOnly

Request Body

In diesem Beispiel werden die Grunddaten für die 1. Variante angelegt:

  • ProductId
  • Price
  • StockAmount
  • Sku

{
   "ProductId": "1"
   "Price": "17.99",
   "StockAmount": "17",
   "Sku": "T-Shirt-Rot-S"
}

Response

Response HTTP-Header


Status Code:            201 Created
Cache-Control:          no-cache
Content-Length:         2154
Content-Type:           application/atom+xml;charset=utf-8
DataServiceVersion:     1.0;
...

Response Body


{
"d" : {
"__metadata" : {

"uri" : "http://sandboxapi.via.de/PublicApi/v1/Api.svc/ProductVariations(1L)",
"type" : "Via.BlackBox.Entities.Api.ProductVariation"

},
"Id" : "1",
"ProductId" : "1",
"Price" : "17.99",
"StockAmount" : 17,
"Sku" : "T-Shirt-Rot-S",
"Product" : {

"__deferred" : {

"uri" : "http://sandboxapi.via.de/PublicApi/v1/Api.svc/ProductVariations(1L)/Product"

}

},
"ProductVariationSpecifics" : {

"__deferred" : {

"uri" : "http://sandboxapi.via.de/PublicApi/v1/Api.svc/ProductVariations(1L)/ProductVariationSpecifics"

}

},
"ListingItems" : {

"__deferred" : {

"uri" : "http://sandboxapi.via.de/PublicApi/v1/Api.svc/ProductVariations(1L)/ListingItems"

}

},
"SalesOrderItems" : {

"__deferred" : {

"uri" : "http://sandboxapi.via.de/PublicApi/v1/Api.svc/ProductVariations(1L)/SalesOrderItems"

}
}
}
}


Von unserem System wurde diesem neuen Entity eine eindeutige Id 1 zugewiesen.
Tags:
Erstellt von Thomas Hoffmann am 2012/11/22 13:50

Copyright 2004-2023 XWiki