# API Article kein result

**URL:** https://forum.shopware.com/t/api-article-kein-result/90296
**Category:** Shopware 5
**Created:** [13. September 2021 um 20:54 UTC](https://forum.shopware.com/t/api-article-kein-result/90296 "2021-09-13T20:54:15Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)
#### Post date: [13. September 2021 um 20:54 UTC](https://forum.shopware.com/t/api-article-kein-result/90296/1 "2021-09-13T20:54:15Z")

</div>

Ich habe ein Importscript mit der API-Classe(PHP) welches seriell befeuert wird von einer Weboberfläche.

Der Return ist so geregelt:

```php
$out = $client->post('articles/', $params);
    print_r($out);

```

Damit bekomm ich normalerweise ergebnisse zurück wie sowas:

```php
{"success":true,"data":{"id":197958,"location":"https:\/\/example.de\/api\/articles\/197958"}}

```

Nach einer mir unbekannten Anzahl von Importen kann es passieren, dass mit nichts zurückgegeben wird, also ein leerer return.

Im Server Errorlog steht dann folgendes:

```php
2021/09/13 22:00:02 [error] 2696#2696: *3273465 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class 'Shopware\Models\Attribute\Article' not found in /var/www/clients/client1/web1/web/engine/Shopware/Models/Article/Detail.php:324
Stack trace:
#0 /var/www/clients/client1/web1/web/engine/Shopware/Components/Api/Resource/Article.php(482): Shopware\Models\Article\Detail->__construct()
#1 /var/www/clients/client1/web1/web/engine/Shopware/Components/Api/Resource/Article.php(959): Shopware\Components\Api\Resource\Article->prepareMainDetail()
#2 /var/www/clients/client1/web1/web/engine/Shopware/Components/Api/Resource/Article.php(317): Shopware\Components\Api\Resource\Article->prepareAssociatedData()
#3 /var/www/clients/client1/web1/web/engine/Shopware/Controllers/Api/Articles.php(97): Shopware\Components\Api\Resource\Article->create()
#4 /var/www/clients/client1/web1/web/engine/Library/Enlight/Controller/Action.php(192): Shopware_Controllers_Api_Articles->postAction()
#5 /var/www/clients/client1/web1/web/engine/Library/Enlight/Controller/Dispatcher/De" while reading response header from upstream, client: IP, server: example.com, request: "POST /api/articles/? HTTP/1.1", upstream: "fastcgi://unix:/var/lib/php5-fpm/web1.sock:", host: "example.com"

```

Weiss jemand was das zu bedeiuten hat?

Danke und Gruss

---

<div class="post-metadata">

### Author: ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)
#### Post date: [14. September 2021 um 07:18 UTC](https://forum.shopware.com/t/api-article-kein-result/90296/2 "2021-09-14T07:18:35Z")

</div>

> [@brettvormkopp](#):
>
> `'Shopware\Models\Attribute\Article'`

Die Klasse ‚Shopware\Models\Attribute\Article‘ wurde nicht gefunden, aber aufgerufen. Schau mal, ob die Klasse in entsprechendem Script eingebunden ist. Falls nicht, mache das und schaue was passiert.

---

<div class="post-metadata">

### Author: ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)
#### Post date: [18. September 2021 um 12:06 UTC](https://forum.shopware.com/t/api-article-kein-result/90296/3 "2021-09-18T12:06:47Z")

</div>

Ich kann den Fehler zwar nicht abfangen mit try/catch, aber ich kann ihn ignorieren.

LieferantDB \> HTML Oberfläche \> JS-fetch ( **jetzt mit catch** ) \> Shopware Api

Dann läuft das Script wenigsten weiter.

Falls jemand weiss wie man hier einen Fehler abfängt wär ich sehr dankbar.

```php
$out = $client->post('articles/', $params);
print_r($out);

```

folgend funktioniert leider nicht, bzw die ganze PHP Seite in ein try/catch zu hüllen bringt auch nix

```php
try {
            $out = $client->post('articles/', $params);
            print_r($out);
        } catch (Exception $e) {
            echo '{"success":false,"message":"API Response Error"}';
        }

```

---

<div class="post-metadata">

### Author: ![phil](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/phil/32/13661_2.png) [@phil](https://forum.shopware.com/u/phil)
#### Post date: [18. September 2021 um 13:33 UTC](https://forum.shopware.com/t/api-article-kein-result/90296/4 "2021-09-18T13:33:11Z")

</div>

Evtl ein Problem mit dem namespace, das ist so eine PHP Eigenart, bist du in einem namespace sucht er nach namespace\Exception und das gibts halt nicht.

Versuchs mal mit

```auto
catch (\Exception $e)

```

also einem Backslash vor Exception.

LG Phil

---

<div class="post-metadata">

### Author: ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)
#### Post date: [19. September 2021 um 09:27 UTC](https://forum.shopware.com/t/api-article-kein-result/90296/5 "2021-09-19T09:27:49Z")

</div>

Vielen Dank für diesen Tip.
