# Eigenes Freitextfeld über Rest API befüttern

**URL:** <https://forum.shopware.com/t/eigenes-freitextfeld-uber-rest-api-befuttern/43757>\
**Category:** Allgemein\
**Created:** [16. Februar 2017 um 08:27 UTC](https://forum.shopware.com/t/eigenes-freitextfeld-uber-rest-api-befuttern/43757 "2017-02-16T08:27:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gomeZ](https://avatars.discourse-cdn.com/v4/letter/g/d78d45/32.png) [@gomeZ](https://forum.shopware.com/u/gomeZ)\
**Post date:** [16. Februar 2017 um 08:27 UTC](https://forum.shopware.com/t/eigenes-freitextfeld-uber-rest-api-befuttern/43757/1 "2017-02-16T08:27:39Z")

</div>

Hallo zusammen,  
leider habe ich zu dem Thema nichts passendes gefunden. Ich habe über ein eigenes Plugin ein neues Feld (mein\_eigenes\_feld) in der Tabelle **s\_articles\_attributes** hinzugefügt.

Nun versuche ich dieses Feld via PUT/POST über die Rest API zu befüttern. Leider ohne Erfolg.

- Habe ich den richtigen Knoten gewählt?
- Ist das generell überhaupt möglich oder muss ich hierfür die API erweitern?

Zum testen habe ich die shopware Git Version getestet und das aktuelle Release 5.2.18.

```
$updateArticle = array(
    'attribute' => array(
        'mein_eigenes_feld' => 6,
        //oder: 'meinEigenesFeld' => 6,
    ),
);

$response = $client->put('articles/3', $updateArticle);

```

Hoffe Ihr könnt mit helfen. Vielen Dank schonmal an alle die Antworten.

---

<div class="post-metadata">

**Author:** ![matthiasftl](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@matthiasftl](https://forum.shopware.com/u/matthiasftl)\
**Post date:** [16. Februar 2017 um 08:59 UTC](https://forum.shopware.com/t/eigenes-freitextfeld-uber-rest-api-befuttern/43757/2 "2017-02-16T08:59:47Z")

</div>

Da fehlt noch was. Hieraus kannst du aus unserem Beispiel die Befüllung der Attr. herleiten. Bei dir fehlt noch ‚mainDetail‘

&nbsp;

&nbsp;

// Artikel neu anlegen da nicht vorhanden  
$ergebnis = $client-\>post(‚articles‘, array(  
&nbsp;&nbsp;&nbsp; ‚name‘ =\> $sw\_name,

&nbsp;&nbsp;&nbsp; ‚categories‘ =\> array(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; array(‚id‘ =\> 151)  
&nbsp;&nbsp;&nbsp; ),  
&nbsp;&nbsp; &nbsp;  
&nbsp;&nbsp;&nbsp; ‚related‘ =\> array(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; array(‚number‘ =\> ‚SW10012‘),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; array(‚number‘ =\> ‚SW10017‘),  
&nbsp;&nbsp;&nbsp; ),  
&nbsp;&nbsp; &nbsp;  
&nbsp;&nbsp;&nbsp; ‚taxId‘ =\> 1,  
&nbsp;&nbsp;&nbsp; ‚supplierId‘ =\> 1,  
&nbsp;&nbsp;&nbsp; ‚active‘ =\> 1,  
&nbsp;&nbsp;&nbsp; ‚keywords‘ =\> $keys,  
&nbsp;&nbsp;&nbsp; ‚mainDetail‘ =\> array(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚number‘ =\> $sw\_number,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚active‘ =\> 1,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚inStock‘ =\> 1000,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚attribute‘ =\> array(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚attr4‘ =\> ‚500044‘  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; array(‚link‘ =\> $bildfotolia,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚description‘ =\> ‚Test‘  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ))  
)));

---

<div class="post-metadata">

**Author:** ![gomeZ](https://avatars.discourse-cdn.com/v4/letter/g/d78d45/32.png) [@gomeZ](https://forum.shopware.com/u/gomeZ)\
**Post date:** [16. Februar 2017 um 09:06 UTC](https://forum.shopware.com/t/eigenes-freitextfeld-uber-rest-api-befuttern/43757/3 "2017-02-16T09:06:33Z")

</div>

Hallo [matthiasftl](https://forum.shopware.com/profile/20638/matthiasftl)  
&nbsp;Danke für deine schnelle Antwort. Hatte ich vergessen mit zu erwähnen. Diese Variante hatte ich auch probiert (nur bei PUT) aber ebenfalls ohne Erfolg. Folgende Varianten hatte ich getestet:

```
// Variante 1
$updateArticle = array(
    'mainDetail' => array(
        'attribute' => array(
            'attr1' => 'Freitext attr' . mt_rand(1,1000),
            'mein_eigenes_feld' => 6,
        ),
    ),
);

// Variante 2
$updateArticle = array(
    'mainDetail' => array(
        'attribute' => array(
            'attr1' => 'Freitext attr' . mt_rand(1,1000),
            'meinEigenesFeld' => 6,
        ),
    ),
);

// Variante 3
$updateArticle = array(
        'attribute' => array(
            'attr1' => 'Freitext attr' . mt_rand(1,1000),
            'mein_eigenes_feld' => 6,
        ),
);

// Variante 4
$updateArticle = array(
        'attribute' => array(
            'attr1' => 'Freitext attr' . mt_rand(1,1000),
            'meinEigenesFeld' => 6,
        ),
);

```

Ich werde es jetzt nochmal mit einem POST probieren. Aber PUT sollte ja auch funktionieren, da ich ja ggf. später eine Änderung daran durchführen möchte.

---

<div class="post-metadata">

**Author:** ![gomeZ](https://avatars.discourse-cdn.com/v4/letter/g/d78d45/32.png) [@gomeZ](https://forum.shopware.com/u/gomeZ)\
**Post date:** [20. Februar 2017 um 09:53 UTC](https://forum.shopware.com/t/eigenes-freitextfeld-uber-rest-api-befuttern/43757/4 "2017-02-20T09:53:56Z")

</div>

Hat einer noch eine Idee oder eine kurze Info was man da machen kann?

---

<div class="post-metadata">

**Author:** ![gomeZ](https://avatars.discourse-cdn.com/v4/letter/g/d78d45/32.png) [@gomeZ](https://forum.shopware.com/u/gomeZ)\
**Post date:** [21. Februar 2017 um 16:45 UTC](https://forum.shopware.com/t/eigenes-freitextfeld-uber-rest-api-befuttern/43757/5 "2017-02-21T16:45:35Z")

</div>

Es funktioniert jetzt ohne Probleme mit der unten verwendeten Variante, sowohl bei POST, als auch bei PUT. Problem war hier noch, dass ich im Backend eine Combobox verwendet habe, welches mit einem Key-Value Paar arbeitet. Es gibt zwar den Key mit der Zahl 6, dieser muss aber beim anlegen der ComboBox als _String_ übergeben werden, sonst wurde zwar die 6 in der DB gespeichert, aber nicht der korrekte Value angezeigt. Hier muss man wohl generell mit Text-Keys arbeiten.

```
// Variante 2
$updateArticle = array(
    'mainDetail' => array(
        'attribute' => array(
            'attr1' => 'Freitext attr' . mt_rand(1,1000),
            'meinEigenesFeld' => '6',
        ),
    ),
);

```

&nbsp;

&nbsp;

&nbsp;
