# REST API PUT Articles Cannot unset string offsets in bei

**URL:** <https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357>\
**Category:** Shopware 3.5\
**Tags:** programming\
**Created:** [19. Mai 2014 um 09:59 UTC](https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357 "2014-05-19T09:59:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rthsw](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rthsw](https://forum.shopware.com/u/rthsw)\
**Post date:** [19. Mai 2014 um 09:59 UTC](https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357/1 "2014-05-19T09:59:48Z")

</div>

Hi, ich wollte einen Artikel mit rudimentären Daten Aktualisieren. 1. Schritt: POST für die ANlage: Erfolgreich, ID wurde zurück geliefert: {“success”:true,“data”:{“id”:9636,“location”:“[http://niexxxxxxxxxxxop.de/api/articles/9636](http://niexxxxxxxxxxxop.de/api/articles/9636)”}} 2. Schritt: active=true und Lagerbestand sollten übergeben werden. PUT-String: {“name”:“Kugelmulde 70 ltr CNS nahtlos tiefgezogen, fahrbare Ausfhrung”,“active”:true,“taxId”:1,“mainDetail”:{“number”:“AMME0004”,“inStock”:0}} Antwort der API:  
**Fatal error** : Cannot unset string offsets in **/home/niederbe/public\_html/engine/Shopware/Components/Api/Resource/Article.php** on line **993**  
503 Service Unavailable Was will mir die API damit sagen? Gibt es generell eine Möglichkeit eien API-Fehler detaillierter erklärt zu bekommen? Beispiel: Auf PUT {“name”:“Regal Alu 93x43x180 cm 4 Ablagen stufenlos h”henverstellbar”,“active”:true,“taxId”:1,“mainDetail”:{“number”:“AMRE0001”,“inStock”:2,“prices”:{{“customerGroupKey”:“LISTE”,“from”:1,“price”:175}}}} bekomme ich {“success”:false,“message”:“Invalid method or invalid json string.”} Ja, das ist mit Sicherheit auch richtig, aber so eine Fehlermeldung macht es einem Shopware-Neuling unglaublich schwierig den Einstieg zu finden. Klammern falsch gesetzt? Tippfehler? Formatierungsfehler? Muss LISTE erst angelegt werden bevor es benutzt werden kann? Die API weis ja warum sie ihre Vorgang abbricht. Es wäre supertoll wenn Sie den Grund auch zurück liefern würde oder Ihn zumindest in ein Log schreibt. Vielleicht macht Sie das ja? Wo?

---

<div class="post-metadata">

**Author:** ![Neox](https://avatars.discourse-cdn.com/v4/letter/n/b5a626/32.png) [@Neox](https://forum.shopware.com/u/Neox)\
**Post date:** [20. Mai 2014 um 09:05 UTC](https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357/2 "2014-05-20T09:05:03Z")

</div>

Hallo, der betroffene Code-Teil: ` /\*\* \* @param array $data \* @param \Shopware\Models\Article\Article $article \* @throws \Shopware\Components\Api\Exception\CustomValidationException \* @return array \*/ protected function prepareArticleAssociatedData($data, ArticleModel $article) { //check if a tax id is passed and load the tax model or set the tax parameter to null. if (!empty($data['taxId'])) { $data['tax'] = $this-\>getManager()-\>find('Shopware\Models\Tax\Tax', $data['taxId']); if (empty($data['tax'])) { throw new ApiException\CustomValidationException(sprintf("Tax by id %s not found", $data['taxId'])); } } elseif (!empty($data['tax'])) { $tax = $this-\>getManager()-\>getRepository('Shopware\Models\Tax\Tax')-\>findOneBy(array('tax' =\> $data['tax'])); if (!$tax) { throw new ApiException\CustomValidationException(sprintf("Tax by taxrate %s not found", $data['tax'])); } $data['tax'] = $tax; } else { unset($data['tax']); } `

---

<div class="post-metadata">

**Author:** ![Neox](https://avatars.discourse-cdn.com/v4/letter/n/b5a626/32.png) [@Neox](https://forum.shopware.com/u/Neox)\
**Post date:** [21. Mai 2014 um 11:24 UTC](https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357/3 "2014-05-21T11:24:47Z")

</div>

Hi, inzwischen habe ich auch schon ausprobiert statt taxID einfach nur tax zu verwenden (laut dem Code sucht die Api dann nach dem Steuersatz statt nach der ID), und unset (taxId) statt unset (tax) im Quellcode, aber das Verhalten ändert sich überhaubt nicht. Ist 503 Service Unavailable vielleicht das wichtiger? Aber was will mir das sagen?

---

<div class="post-metadata">

**Author:** ![ottscho](https://avatars.discourse-cdn.com/v4/letter/o/7ba0ec/32.png) [@ottscho](https://forum.shopware.com/u/ottscho)\
**Post date:** [13. Februar 2015 um 14:43 UTC](https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357/4 "2015-02-13T14:43:13Z")

</div>

Konntest du das Problem lösen? Ich habe es auch teilweise bei einigen Artikel welche ich update. Aber andere Artikel funktionieren wieder. Vergleicht man das Array der funktionierenden Artikel mit den anderen gibt es aber keinen Unterschied. Die Ursache ist das unset der $data[tax] [https://github.com/shopware/shopware/bl … rticle.php](https://github.com/shopware/shopware/blob/master/engine/Shopware/Components/Api/Resource/Article.php) Zeile 1025. Das ist kein Array und kann deshalb nicht mit unset gelöscht werden. Aber wie dies zustande kommt ist mir unklar.

---

<div class="post-metadata">

**Author:** ![ottscho](https://avatars.discourse-cdn.com/v4/letter/o/7ba0ec/32.png) [@ottscho](https://forum.shopware.com/u/ottscho)\
**Post date:** [17. Februar 2015 um 08:01 UTC](https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357/5 "2015-02-17T08:01:47Z")

</div>

niemand eine Idee?

---

<div class="post-metadata">

**Author:** ![Chris.W](https://avatars.discourse-cdn.com/v4/letter/c/ad7895/32.png) [@Chris.W](https://forum.shopware.com/u/Chris.W)\
**Post date:** [18. Juni 2015 um 11:52 UTC](https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357/6 "2015-06-18T11:52:46Z")

</div>

Konnte mittlerweile jemand das Problem lösen?

---

<div class="post-metadata">

**Author:** ![holzprofi24](https://avatars.discourse-cdn.com/v4/letter/h/6f9a4e/32.png) [@holzprofi24](https://forum.shopware.com/u/holzprofi24)\
**Post date:** [28. September 2015 um 15:32 UTC](https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357/7 "2015-09-28T15:32:03Z")

</div>

Immer noch keine Lösung oder Erklärung bei diesem Problem ?

---

<div class="post-metadata">

**Author:** ![RedEars](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@RedEars](https://forum.shopware.com/u/RedEars)\
**Post date:** [17. Dezember 2015 um 17:26 UTC](https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357/8 "2015-12-17T17:26:49Z")

</div>

Sitze leider seit Ewigkeiten am selben Problem und kann es einfach nicht lösen. Habt ihr mittlerweile eine Lösung gefunden?

---

<div class="post-metadata">

**Author:** ![Wolfacom](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@Wolfacom](https://forum.shopware.com/u/Wolfacom)\
**Post date:** [22. Februar 2016 um 22:12 UTC](https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357/9 "2016-02-22T22:12:30Z")

</div>

Bei uns lag das Problem daran, dass wir versehentlich PUT statt POST verwendet haben.

Dadurch dachte Shopware, das der Artikel bereits existiert und versucht auf die nicht existierende TaxId zuzugreifen.

&nbsp;

---

<div class="post-metadata">

**Author:** ![langnickel](https://avatars.discourse-cdn.com/v4/letter/l/3ec8ea/32.png) [@langnickel](https://forum.shopware.com/u/langnickel)\
**Post date:** [30. Juni 2017 um 10:55 UTC](https://forum.shopware.com/t/rest-api-put-articles-cannot-unset-string-offsets-in-bei/20357/10 "2017-06-30T10:55:58Z")

</div>

Bei mir lag es an einer falschen Zeichenkodierung bzw an einem einzigen Falsch kodierten Zeichen im „description“ feld.&nbsp;
