# REST-API: Artikel mit Varianten anlegen klappt nicht

**URL:** <https://forum.shopware.com/t/rest-api-artikel-mit-varianten-anlegen-klappt-nicht/31366>\
**Category:** Programmierung\
**Created:** [14. Oktober 2015 um 13:50 UTC](https://forum.shopware.com/t/rest-api-artikel-mit-varianten-anlegen-klappt-nicht/31366 "2015-10-14T13:50:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![britter](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@britter](https://forum.shopware.com/u/britter)\
**Post date:** [14. Oktober 2015 um 13:50 UTC](https://forum.shopware.com/t/rest-api-artikel-mit-varianten-anlegen-klappt-nicht/31366/1 "2015-10-14T13:50:46Z")

</div>

Hallo zusammen, ich möchte einen Shop (Shopware 5.0.4) von außen per REST-API mit Artikeldaten füllen. Der Artikel lässt sich anlegen, jedoch als die Varianten dazukamen, stieß ich auf Probleme. Der Artikel 999 ist z.B. in drei Varianten verfügbar (999.01, 999.02, 999.03), wobei 01 die Standard-Variante ist, soweit kein Problem. Übertrage ich das jetzt per REST (JSON) erzeugt Shopware zwar den Hauptartikel und die Artikel in article\_details, jedoch sind die nicht als Varianten verknüpft. Wenn ich im Backend dann schaue, dann kann ich die Varianten immer noch generieren und habe ich nicht bestehenden Varianten vor mir. Probeweise habe ich die Varianten dann mal generieren lassen, jedoch hat er dann nicht meine vorgegebenen Artikelnummern genommen, sondern nur von der Hauptvarianten + fortlaufende Zahl. Ich habe es bereits mit dem Anlegen des Artikels per REST probiert und dem nachträglichen Aktualisieren der Variants. Komme ich jedoch zu demselben Problem. [http://imgur.com/Z8IJnMz](http://imgur.com/Z8IJnMz) [http://imgur.com/4Ehh3gr](http://imgur.com/4Ehh3gr) Anbei das JSON-Request, dass ich ausführe: `{ "name": "Rasenmäher", "active": true, "tax": 19, "supplier": "Leitz", "description": "I am a description", "descriptionLong": "I am a long description", "categories": [{ "id": 1110 }], "priceGroupId": 1, "priceGroupActive": true, "mainDetail": { "number": "999" }, "configuratorSet": { "groups": [{ "name": "Variation", "options": [{ "name": "01" }, { "name": "02" }, { "name": "03" }] } ] }, "variants": [{ "number": "999.01", "active": true, "isMain": true, "inStock": 125, "kind": 1, "prices": [{ "from": 1, "to": "beliebig", "price": 2.99 }], "configuratorOptions": [{ "name": "01" }] }, { "number": "999.02", "active": true, "inStock": 222, "kind": 2, "prices": [{ "from": 1, "to": "beliebig", "price": 2.99 }], "configuratorOptions": [{ "name": "02" }] }, { "number": "999.03", "active": true, "inStock": 888, "kind": 2, "prices": [{ "from": 1, "to": "beliebig", "price": 2.99 }], "configuratorOptions": [{ "name": "03" }] } ] }`

---

<div class="post-metadata">

**Author:** ![Robert\_Dreher](https://avatars.discourse-cdn.com/v4/letter/r/a6a055/32.png) [@Robert\_Dreher](https://forum.shopware.com/u/Robert_Dreher)\
**Post date:** [7. Juni 2017 um 12:34 UTC](https://forum.shopware.com/t/rest-api-artikel-mit-varianten-anlegen-klappt-nicht/31366/2 "2017-06-07T12:34:30Z")

</div>

Hallo aus Österreich,

ich habe beim Anlegen von Artikeln mit drei Varianten&nbsp; per REST API über den Artikel Endpunkt ein ähnliches Problem.

Wenn ich folgendes JSON Request ausführe

_{  
&nbsp;&nbsp; &nbsp;“name”: “Test Variantenartikel Schuhe”,  
&nbsp;&nbsp; &nbsp;“taxId”: 1,  
&nbsp;&nbsp; &nbsp;“active”: true,  
&nbsp;&nbsp; &nbsp;“price”: 300.25,  
&nbsp;&nbsp; &nbsp;“supplier”: “BASL GmbH - Softwarelösungen nach Maß”,  
&nbsp;&nbsp; &nbsp;“categories”: {  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“11”: {  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“id”: “11”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“name”: “Maschinen + Ger\u00e4te”  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}  
&nbsp;&nbsp; &nbsp;},  
&nbsp;&nbsp; &nbsp;“mainDetail”: {  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“number”: “Test.01”  
&nbsp;&nbsp; &nbsp;},  
&nbsp;&nbsp; &nbsp;“configuratorSet”: [{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“name”: “My\_shoe\_config”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“groups”: [{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“name”: “Color”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“options”: [{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“name”: “White”  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;},  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“name”: “Yellow”  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;},  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“name”: “Blue”  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;},  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“name”: “Black”  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}]  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}]  
&nbsp;&nbsp; &nbsp;}],  
&nbsp;&nbsp; &nbsp;“variants”: [{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“active”: true,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“number”: “Test.01.1”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“inStock”: 15,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“additionaltext”: “S / Schwarz”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“configuratorOptions”: [{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“group”: “Color”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“option”: “Black”  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}],  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“prices”: [{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“customerGroupKey”: “H”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“from”: 1,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“to”: 20,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“price”: 15  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;},  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“customerGroupKey”: “EK”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“price”: 15  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;},  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“customerGroupKey”: “H”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“from”: 20,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“to”: “”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“price”: 10  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}]  
&nbsp;&nbsp; &nbsp;},  
&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“number”: “Test.01.2”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“active”: true,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“inStock”: 10,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“additionaltext”: “S / White”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“configuratorOptions”: [{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“group”: “Color”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“option”: “White”  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}],  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“prices”: [{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“customerGroupKey”: “H”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“price”: 25  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;},  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“customerGroupKey”: “EK”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“price”: 25  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}]  
&nbsp;&nbsp; &nbsp;},  
&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“number”: “Test.01.3”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“active”: true,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“inStock”: 5,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“additionaltext”: “S / Blue”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“configuratorOptions”: [{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“group”: “Color”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“option”: “Blue”  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}],  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“prices”: [{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“customerGroupKey”: “H”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“price”: 30  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;},  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“customerGroupKey”: “EK”,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;“price”: 30  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;]  
&nbsp;&nbsp; &nbsp;}  
&nbsp;&nbsp; &nbsp;]  
}_

&nbsp;

dann ist nur der Grundartikel im Backend sichtbar.

Sehe mich mir den Artikel direkt in der Datenbank an, so ist er in der Tabelle “s\_articles” vorhanden und in der Tabelle “s\_articles\_details” sind die Varianten nicht vorhanden.

Weiters ist mir aufgefallen, daß nur mehr die Daten in der Tabelle “s\_article\_configurator-sets” stehen, aber die anderen Tabellen “s\_article\_configurator\_groups”, “s\_article\_configurator\_options”, “s\_article\_configurator\_option\_relations”,“s\_article\_configurator\_set\_group\_relations”, “s\_article\_configurator\_set\_option\_relations” nicht mit Daten befüllt werden. Nur wenn ich diese Tabellen per Hand mit den richtigen Daten befülle, kann ich auch die Varianten im Backend sehen.&nbsp;

Meine Frage wäre hast du dein Problem lösen können?

Was mach ich falsch, bzw was fehlt noch im JSON Request?

&nbsp;

Liebe Grüße

Robert

&nbsp;

&nbsp;

&nbsp;

&nbsp;
