# API Response bei Media-Upload leer (Status 204)

**URL:** <https://forum.shopware.com/t/api-response-bei-media-upload-leer-status-204/67678>\
**Category:** Programmierung\
**Created:** [15. Juni 2020 um 18:21 UTC](https://forum.shopware.com/t/api-response-bei-media-upload-leer-status-204/67678 "2020-06-15T18:21:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bugfree](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/bugfree/32/13827_2.png) [@bugfree](https://forum.shopware.com/u/bugfree)\
**Post date:** [15. Juni 2020 um 18:21 UTC](https://forum.shopware.com/t/api-response-bei-media-upload-leer-status-204/67678/1 "2020-06-15T18:21:50Z")

</div>

Hallo zusammen,

ich habe einen Bildupload programmiert, welcher auch prima funktioniert.  
Leider bekommen ich eine leere Response (204) auf den API-Request \_action/media/media-ID/upload?extension=jpg&fileName=bildname  
Ich würde jedoch gerne die Antwort darauf hin prüfen, ob der Bilduload erfogreich gewesen ist.  
Der GET-Parameter &\_response=basic bzw. ?\_response=basic am Anfang der Query bringt nichts.

Gibt es da eine Möglichkeit?

---

<div class="post-metadata">

**Author:** ![Loki1](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@Loki1](https://forum.shopware.com/u/Loki1)\
**Post date:** [22. Juni 2020 um 11:21 UTC](https://forum.shopware.com/t/api-response-bei-media-upload-leer-status-204/67678/2 "2020-06-22T11:21:04Z")

</div>

Hallo,

ich mache das mit “?\_response=true”. So bekomme ich u.a. den Status-Code zurück.

---

<div class="post-metadata">

**Author:** ![Loki1](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@Loki1](https://forum.shopware.com/u/Loki1)\
**Post date:** [22. Juni 2020 um 12:20 UTC](https://forum.shopware.com/t/api-response-bei-media-upload-leer-status-204/67678/3 "2020-06-22T12:20:53Z")

</div>

media-ID ist die ID des Folders? Seit dem Major Release funktioniert genau das bei mir nicht mehr.

---

<div class="post-metadata">

**Author:** ![bugfree](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/bugfree/32/13827_2.png) [@bugfree](https://forum.shopware.com/u/bugfree)\
**Post date:** [22. Juni 2020 um 12:55 UTC](https://forum.shopware.com/t/api-response-bei-media-upload-leer-status-204/67678/4 "2020-06-22T12:55:34Z")

</div>

> [@Loki\_ schrieb:](https://forum.shopware.com/profile/34263/Loki_ "Loki\_")
> 
> Hallo,
> 
> ich mache das mit „?\_response=true“. So bekomme ich u.a. den Status-Code zurück.

@Loki: Vielen Dank für den Hinweis.

Ich habe den Bildupload mit folgenden Test-Requests durchgeführt:

1. \_action/media/media-ID/upload **?\_response=true** &extension=jpg&fileName=bildname
2. \_action/media/media-ID/upload?extension=jpg&fileName=bildname **&\_response=true**

In beiden Fällen erhalte ich den Status-Code 204 und eine leere Response.  
Der Shop läuft in Version 6.2.2

---

<div class="post-metadata">

**Author:** ![bugfree](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/bugfree/32/13827_2.png) [@bugfree](https://forum.shopware.com/u/bugfree)\
**Post date:** [22. Juni 2020 um 13:04 UTC](https://forum.shopware.com/t/api-response-bei-media-upload-leer-status-204/67678/5 "2020-06-22T13:04:51Z")

</div>

> [@Loki\_ schrieb:](https://forum.shopware.com/profile/34263/Loki_ "Loki\_")
> 
> media-ID ist die ID des Folders? Seit dem Major Release funktioniert genau das bei mir nicht mehr.

Bei **Neuanlage** des Bildes, also wenn das Bild noch nicht existiert, übergebe ich als media-ID die product\_media\_id, wobei zuvor ein Platzhalter-Bild mit POST-Request&nbsp;'api/v1/media und folgendem Payload erzeugt wird:

```
$aPostData = [
  'mediaFolderId' => $this->sMediaFolderId, // media folder id
  'mediaId' => $this->createProductMediaId($sProductId, $iImgIndex), // product media id
  'id' => $this->createProductImageId($sProductId, $iImgIndex), // product image id
  'includes' => ['id']
];

```

Beim Update des Bildes übergebe ich als ich als media-ID die die ID des des Bildes.

Wie bereits erwähnt funktionieren sowohl die Neuanlage, als auch das Update des Bildes.
